From e52e1db5ab49c1942778139ac1f746078d854414 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Tue, 15 Aug 2023 21:45:56 +0000 Subject: [PATCH] applemedia: Fix pixel format for I420 In Intel Macs, using full range 8-bit 4:2:0 YCbCr results in a failure on initialization. I've validated this to be the correct pixel format with FFmpeg: https://github.com/FFmpeg/FFmpeg/blob/8653dcaf7d665b15b40ea9a560c8171b0914a882/libavutil/hwcontext_videotoolbox.c#L45 Part-of: --- subprojects/gst-plugins-bad/sys/applemedia/coremediabuffer.c | 2 ++ subprojects/gst-plugins-bad/sys/applemedia/corevideobuffer.c | 2 ++ subprojects/gst-plugins-bad/sys/applemedia/helpers.c | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-bad/sys/applemedia/coremediabuffer.c b/subprojects/gst-plugins-bad/sys/applemedia/coremediabuffer.c index 70877d77f5..2bdebb65b7 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/coremediabuffer.c +++ b/subprojects/gst-plugins-bad/sys/applemedia/coremediabuffer.c @@ -123,6 +123,8 @@ static GstVideoFormat gst_core_media_buffer_get_video_format (OSType format) { switch (format) { + case kCVPixelFormatType_420YpCbCr8Planar: + return GST_VIDEO_FORMAT_I420; case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: return GST_VIDEO_FORMAT_NV12; case kCVPixelFormatType_422YpCbCr8_yuvs: diff --git a/subprojects/gst-plugins-bad/sys/applemedia/corevideobuffer.c b/subprojects/gst-plugins-bad/sys/applemedia/corevideobuffer.c index f154efcf70..409c6ac7dc 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/corevideobuffer.c +++ b/subprojects/gst-plugins-bad/sys/applemedia/corevideobuffer.c @@ -216,6 +216,8 @@ static GstVideoFormat gst_core_video_get_video_format (OSType format) { switch (format) { + case kCVPixelFormatType_420YpCbCr8Planar: + return GST_VIDEO_FORMAT_I420; case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: return GST_VIDEO_FORMAT_NV12; case kCVPixelFormatType_422YpCbCr8_yuvs: diff --git a/subprojects/gst-plugins-bad/sys/applemedia/helpers.c b/subprojects/gst-plugins-bad/sys/applemedia/helpers.c index 68f1b3a2dd..8a4dbe612a 100644 --- a/subprojects/gst-plugins-bad/sys/applemedia/helpers.c +++ b/subprojects/gst-plugins-bad/sys/applemedia/helpers.c @@ -59,7 +59,7 @@ gst_video_format_to_cvpixelformat (GstVideoFormat fmt) switch (fmt) { /* YUV */ case GST_VIDEO_FORMAT_I420: - return kCVPixelFormatType_420YpCbCr8PlanarFullRange; + return kCVPixelFormatType_420YpCbCr8Planar; case GST_VIDEO_FORMAT_NV12: return kCVPixelFormatType_420YpCbCr8BiPlanarFullRange; case GST_VIDEO_FORMAT_UYVY: