From 62d54db07d7b862ec147f2a35bd3eda1a7530b38 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Thu, 1 Oct 2009 02:48:35 +0100 Subject: ffmpeg: VC-1/WMV3 fixes. Use format field in the pad caps to differentiate VC-1 from WMV3. Fix a typo in the caps creation and parsing - the field is called 'format' - not 'fourcc' Add a dodgy hack to populate the extradata size field (first byte) when it is 0 - as it seems to be for some (Matroska) test files. --- ext/ffmpeg/gstffmpegcodecmap.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c index 584be8e..5427a53 100644 --- a/ext/ffmpeg/gstffmpegcodecmap.c +++ b/ext/ffmpeg/gstffmpegcodecmap.c @@ -965,11 +965,12 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id, case CODEC_ID_WMV3: caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv", - "wmvversion", G_TYPE_INT, 3, NULL); + "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC, + GST_MAKE_FOURCC ('W', 'M', 'V', '3'), NULL); break; case CODEC_ID_VC1: caps = gst_ff_vid_caps_new (context, codec_id, "video/x-wmv", - "wmvversion", G_TYPE_INT, 3, "fourcc", GST_TYPE_FOURCC, + "wmvversion", G_TYPE_INT, 3, "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('W', 'V', 'C', '1'), NULL); break; case CODEC_ID_QDM2: @@ -2156,6 +2157,11 @@ gst_ffmpeg_caps_with_codecid (enum CodecID codec_id, context->extradata_size = size; } + /* Hack for VC1. Sometimes the first (length) byte is 0 for some files */ + if (codec_id == CODEC_ID_VC1 && size > 0 && data[0] == 0) { + context->extradata[0] = (guint8) size; + } + GST_DEBUG ("have codec data of size %d", size); } else if (context->extradata == NULL) { /* no extradata, alloc dummy with 0 sized, some codecs insist on reading @@ -2716,12 +2722,15 @@ gst_ffmpeg_caps_to_codecid (const GstCaps * caps, AVCodecContext * context) { guint32 fourcc; - if (gst_structure_get_fourcc (structure, "fourcc", &fourcc)) { + /* WMV3 unless the fourcc exists and says otherwise */ + id = CODEC_ID_WMV3; + + if (gst_structure_get_fourcc (structure, "format", &fourcc)) { if ((fourcc == GST_MAKE_FOURCC ('W', 'V', 'C', '1')) || - (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) + (fourcc == GST_MAKE_FOURCC ('W', 'M', 'V', 'A'))) { id = CODEC_ID_VC1; - } else - id = CODEC_ID_WMV3; + } + } } break; } -- cgit v1.2.3