Skip to content

Commit abb4803

Browse files
andrewsonchaPatTheMavjcm93
committed
Fix: Applied Suggested Changes
Applied changes suggested by @jcm93 and @PatTheMav Co-authored-by: PatTheMav <patthemav+github@gmail.com> Co-authored-by: jcm <6864788+jcm93@users.noreply.github.com>
1 parent c0b94a8 commit abb4803

File tree

6 files changed

+30
-24
lines changed

6 files changed

+30
-24
lines changed

plugins/mac-capture/mac-audio.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,7 @@ static OSStatus input_callback(void *data, AudioUnitRenderActionFlags *action_fl
444444
mach_timebase_info(&info);
445445
factor = ((double)info.numer) / info.denom;
446446
}
447-
if (info.numer != info.denom)
448-
audio.timestamp = (uint64_t)(factor * (double)ts_data->mHostTime);
449-
else
450-
audio.timestamp = ts_data->mHostTime;
447+
audio.timestamp = AudioConvertHostTimeToNanos(ts_data->mHostTime);
451448

452449
obs_source_output_audio(ca->source, &audio);
453450

plugins/mac-capture/mac-sck-common.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,15 @@ bool build_application_list(struct screen_capture *sc, obs_properties_t *props)
275275
needs_to_update_properties = true;
276276
}
277277
} else {
278-
size_t width = CVPixelBufferGetWidth(image_buffer);
279-
size_t height = CVPixelBufferGetHeight(image_buffer);
278+
int width = CVPixelBufferGetWidth(image_buffer);
279+
int height = CVPixelBufferGetHeight(image_buffer);
280280

281-
if (((size_t)sc->frame.size.width != width) || ((size_t)sc->frame.size.height != height)) {
282-
sc->frame.size.width = (CGFloat)width;
283-
sc->frame.size.height = (CGFloat)height;
281+
int frameWidth = (int) sc->frame.size.width;
282+
int frameHeight = (int) sc->frame.size.height;
283+
284+
if ((frameWidth != width) || (frameHeight != height)) {
285+
sc->frame.size.width = width;
286+
sc->frame.size.height = height;
284287
needs_to_update_properties = true;
285288
}
286289
}

plugins/mac-syphon/syphon.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,13 @@ static void syphon_video_tick(void *data, float seconds)
630630
if (s->crop)
631631
crop = &s->crop_rect;
632632

633+
float origin_x = (float) crop->origin.x;
634+
float origin_y = (float) (s->height - crop->origin.y);
635+
float end_x = (float) (s->width - crop->size.width);
636+
float end_y = (float) crop->size.height;
637+
633638
obs_enter_graphics();
634-
build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer), (float) crop->origin.x,
635-
(float) s->height - (float) crop->origin.y, (float) s->width - (float) crop->size.width,
636-
(float) crop->size.height);
639+
build_sprite_rect(gs_vertexbuffer_get_data(s->vertbuffer), origin_x, origin_y, end_x, end_y);
637640
obs_leave_graphics();
638641
}
639642

plugins/mac-videotoolbox/encoder.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,13 @@ static OSStatus create_encoder(struct vt_encoder *enc)
539539
kVTCompressionPropertyKey_AllowFrameReordering,
540540
kVTCompressionPropertyKey_ProfileLevel};
541541

542-
SInt32 key_frame_interval = (SInt32)((float)enc->keyint * ((float)enc->fps_num / (float)enc->fps_den));
543-
float expected_framerate = (float)enc->fps_num / (float)enc->fps_den;
542+
int actual_frame_rate = enc->fps_num / enc->fps_den;
543+
int key_frame_interval = enc->keyint * actual_frame_rate;
544+
544545
CFNumberRef MaxKeyFrameInterval =
545-
CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &key_frame_interval);
546+
CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &key_frame_interval);
546547
CFNumberRef ExpectedFrameRate =
547-
CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat32Type, &expected_framerate);
548+
CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &actual_frame_rate);
548549
CFTypeRef AllowFrameReordering = enc->bframes ? kCFBooleanTrue : kCFBooleanFalse;
549550

550551
video_t *video = obs_encoder_video(enc->encoder);

plugins/mac-virtualcam/src/dal-plugin/CMSampleBufferUtils.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ CMSampleTimingInfo CMSampleTimingInfoForTimestamp(uint64_t timestampNanos, uint3
1919
CMTimeScale scale = 600;
2020
CMSampleTimingInfo timing;
2121
timing.duration = CMTimeMake(fpsDenominator * scale, fpsNumerator * scale);
22-
timing.presentationTimeStamp = CMTimeMakeWithSeconds((double)timestampNanos / (double) NSEC_PER_SEC, scale);
22+
CMTime timestamp = CMTimeMake(timestampNanos, NSEC_PER_SEC);
23+
timing.presentationTimeStamp = CMTimeConvertScale(timestamp, scale, kCMTimeRoundingMethod_QuickTime);
2324
timing.decodeTimeStamp = kCMTimeInvalid;
2425
return timing;
2526
}

plugins/mac-virtualcam/src/dal-plugin/OBSDALStream.mm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ - (NSSize)testCardSize
123123
{
124124
if (NSEqualSizes(_testCardSize, NSZeroSize)) {
125125
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
126-
NSInteger width = [[defaults objectForKey:kTestCardWidthKey] integerValue];
127-
NSInteger height = [[defaults objectForKey:kTestCardHeightKey] integerValue];
126+
double width = [[defaults objectForKey:kTestCardWidthKey] doubleValue];
127+
double height = [[defaults objectForKey:kTestCardHeightKey] doubleValue];
128128
if (width == 0 || height == 0) {
129129
_testCardSize = NSMakeSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
130130
} else {
131-
_testCardSize = NSMakeSize((double)width, (double)height);
131+
_testCardSize = NSMakeSize(width, height);
132132
}
133133
}
134134
return _testCardSize;
@@ -238,9 +238,9 @@ - (CVPixelBufferRef)createPixelBufferWithTestAnimation
238238
NSParameterAssert(pxdata != NULL);
239239

240240
CGColorSpaceRef rgbColorSpace = CGColorSpaceCreateDeviceRGB();
241-
CGContextRef context = CGBitmapContextCreate(pxdata, width, height, 8,
242-
CVPixelBufferGetBytesPerRowOfPlane(pxbuffer, 0), rgbColorSpace,
243-
((int)kCGImageAlphaPremultipliedFirst) | ((int)kCGImageByteOrder32Big));
241+
CGContextRef context =
242+
CGBitmapContextCreate(pxdata, width, height, 8, CVPixelBufferGetBytesPerRowOfPlane(pxbuffer, 0), rgbColorSpace,
243+
(CGBitmapInfo) kCGImageAlphaPremultipliedFirst | kCGImageByteOrder32Big);
244244
CFRelease(rgbColorSpace);
245245
NSParameterAssert(context);
246246

@@ -249,7 +249,8 @@ - (CVPixelBufferRef)createPixelBufferWithTestAnimation
249249

250250
NSRect rect = NSMakeRect(0, 0, self.testCardImage.size.width, self.testCardImage.size.height);
251251
CGImageRef image = [self.testCardImage CGImageForProposedRect:&rect context:nsContext hints:nil];
252-
CGContextDrawImage(context, CGRectMake(0, 0, (double)CGImageGetWidth(image), (double)CGImageGetHeight(image)), image);
252+
CGContextDrawImage(context, CGRectMake(0, 0, (double) CGImageGetWidth(image), (double) CGImageGetHeight(image)),
253+
image);
253254

254255
// DrawDialWithFrame(
255256
// NSMakeRect(0, 0, width, height),

0 commit comments

Comments
 (0)