Commit bf3ab237 authored by François Grisez's avatar François Grisez
Browse files

Workaround to prevent VideoToolbox's H264 encoder from crash on MacOSX

parent cc422c23
...@@ -194,10 +194,22 @@ static void h264_enc_process(MSFilter *f) { ...@@ -194,10 +194,22 @@ static void h264_enc_process(MSFilter *f) {
YuvBuf src_yuv_frame, dst_yuv_frame = {0}; YuvBuf src_yuv_frame, dst_yuv_frame = {0};
CVPixelBufferRef pixbuf; CVPixelBufferRef pixbuf;
CFMutableDictionaryRef enc_param = NULL; CFMutableDictionaryRef enc_param = NULL;
int i; int i, pixbuf_fmt = kCVPixelFormatType_420YpCbCr8Planar;
CFNumberRef value;
CFMutableDictionaryRef pixbuf_attr;
ms_yuv_buf_init_from_mblk(&src_yuv_frame, frame); ms_yuv_buf_init_from_mblk(&src_yuv_frame, frame);
#if TARGET_OS_IPHONE
CVPixelBufferPoolCreatePixelBuffer(NULL, pixbuf_pool, &pixbuf); CVPixelBufferPoolCreatePixelBuffer(NULL, pixbuf_pool, &pixbuf);
#else
pixbuf_attr = CFDictionaryCreateMutable(NULL, 0, NULL, NULL);
value = CFNumberCreate(NULL, kCFNumberIntType, &pixbuf_fmt);
CFDictionarySetValue(pixbuf_attr, kCVPixelBufferPixelFormatTypeKey, value);
CVPixelBufferCreate(NULL, ctx->conf.vsize.width, ctx->conf.vsize.height, kCVPixelFormatType_420YpCbCr8Planar, pixbuf_attr, &pixbuf);
CFRelease(pixbuf_attr);
#endif
CVPixelBufferLockBaseAddress(pixbuf, 0); CVPixelBufferLockBaseAddress(pixbuf, 0);
dst_yuv_frame.w = (int)CVPixelBufferGetWidth(pixbuf); dst_yuv_frame.w = (int)CVPixelBufferGetWidth(pixbuf);
dst_yuv_frame.h = (int)CVPixelBufferGetHeight(pixbuf); dst_yuv_frame.h = (int)CVPixelBufferGetHeight(pixbuf);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment