[FFmpeg-devel] [PATCH 9/9] avcodec/videotoolbox: create avcC even when h264 extradata is missing

Aman Gupta ffmpeg at tmm1.net
Tue Sep 26 03:36:31 EEST 2017


From: Aman Gupta <aman at tmm1.net>

Removes the avctx->extradata_size requirement when creating avcC, since
avctx->extradata is only used in the esds code path.

This fixes an issue where the VideoToolbox decoder would not work unless
avformat_find_stream_info() was called.
---
 libavcodec/videotoolbox.c | 65 +++++++++++++++++++++++------------------------
 1 file changed, 32 insertions(+), 33 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 6c8477c2ce..de51b9a7c4 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -538,46 +538,45 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec
                          kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
                          kCFBooleanTrue);
 
-    if (avctx->extradata_size) {
-        CFMutableDictionaryRef avc_info;
-        CFDataRef data = NULL;
+    CFMutableDictionaryRef avc_info;
+    CFDataRef data = NULL;
 
-        avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
-                                             1,
-                                             &kCFTypeDictionaryKeyCallBacks,
-                                             &kCFTypeDictionaryValueCallBacks);
+    avc_info = CFDictionaryCreateMutable(kCFAllocatorDefault,
+                                         1,
+                                         &kCFTypeDictionaryKeyCallBacks,
+                                         &kCFTypeDictionaryValueCallBacks);
 
-        switch (codec_type) {
-        case kCMVideoCodecType_MPEG4Video :
+    switch (codec_type) {
+    case kCMVideoCodecType_MPEG4Video:
+        if (avctx->extradata_size)
             data = videotoolbox_esds_extradata_create(avctx);
-            if (data)
-                CFDictionarySetValue(avc_info, CFSTR("esds"), data);
-            break;
-        case kCMVideoCodecType_H264 : {
-            H264Context *h = avctx->priv_data;
-            if (TARGET_OS_IPHONE && h->ps.sps->frame_mbs_only_flag == 0) {
-                av_log(avctx, AV_LOG_ERROR, "VideoToolbox cannot decode interlaced fields on iOS\n");
-                CFRelease(avc_info);
-                goto fail;
-            }
-            data = ff_videotoolbox_avcc_extradata_create(avctx);
-            if (data)
-                CFDictionarySetValue(avc_info, CFSTR("avcC"), data);
-            break;
-        }
-        default:
-            break;
+        if (data)
+            CFDictionarySetValue(avc_info, CFSTR("esds"), data);
+        break;
+    case kCMVideoCodecType_H264: {
+        H264Context *h = avctx->priv_data;
+        if (TARGET_OS_IPHONE && h->ps.sps->frame_mbs_only_flag == 0) {
+            av_log(avctx, AV_LOG_ERROR, "VideoToolbox cannot decode interlaced fields on iOS\n");
+            CFRelease(avc_info);
+            goto fail;
         }
+        data = ff_videotoolbox_avcc_extradata_create(avctx);
+        if (data)
+            CFDictionarySetValue(avc_info, CFSTR("avcC"), data);
+        break;
+    }
+    default:
+        break;
+    }
 
-        CFDictionarySetValue(config_info,
-                kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms,
-                avc_info);
+    CFDictionarySetValue(config_info,
+            kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms,
+            avc_info);
 
-        if (data)
-            CFRelease(data);
+    if (data)
+        CFRelease(data);
 
-        CFRelease(avc_info);
-    }
+    CFRelease(avc_info);
     return config_info;
 
 fail:
-- 
2.13.5 (Apple Git-94)



More information about the ffmpeg-devel mailing list