From d986524c71c2e41ce329e9dd5f6c78cb3d6e4de2 Mon Sep 17 00:00:00 2001 From: jstebbins Date: Sun, 6 Nov 2011 01:43:21 +0000 Subject: Fix probing mpeg video in program streams ... and probably some other formats as well. Libav's probe routine doesn't necessarily return names that match the codec names that can be looked up by avcodec_find_decoder_by_name(). So we have to manually map the names if the lookup fails. Lookup for mpeg video started failing with the last Libav bump because they removed an obsolete "mpegvideo" decoder that we were matching on. The correct decoder is "mpeg2video", but probe doesn't return that string. Also fix our implementation of the ff_lockmgr callback. Current git Libav fails if we don't fix it. So might as well fix it now. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4341 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/stream.c | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'libhb/stream.c') diff --git a/libhb/stream.c b/libhb/stream.c index e79920d9b..7765c36a7 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -3907,7 +3907,42 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf ) if ( fmt && score > AVPROBE_SCORE_MAX / 2 ) { AVCodec *codec = avcodec_find_decoder_by_name( fmt->name ); - if ( codec ) + if( !codec ) + { + int i; + static const struct { + const char *name; enum CodecID id; + } fmt_id_type[] = { + { "g722" , CODEC_ID_ADPCM_G722 }, + { "mlp" , CODEC_ID_MLP }, + { "truehd" , CODEC_ID_TRUEHD }, + { "shn" , CODEC_ID_SHORTEN }, + { "aac" , CODEC_ID_AAC }, + { "ac3" , CODEC_ID_AC3 }, + { "dts" , CODEC_ID_DTS }, + { "eac3" , CODEC_ID_EAC3 }, + { "h264" , CODEC_ID_H264 }, + { "m4v" , CODEC_ID_MPEG4 }, + { "mp3" , CODEC_ID_MP3 }, + { "mpegvideo", CODEC_ID_MPEG2VIDEO }, + { "cavsvideo", CODEC_ID_CAVS }, + { "dnxhd" , CODEC_ID_DNXHD }, + { "h261" , CODEC_ID_H261 }, + { "h263" , CODEC_ID_H263 }, + { "mjpeg" , CODEC_ID_MJPEG }, + { "vc1" , CODEC_ID_VC1 }, + { 0 } + }; + for( i = 0; fmt_id_type[i].name; i++ ) + { + if( !strcmp(fmt->name, fmt_id_type[i].name ) ) + { + codec = avcodec_find_decoder( fmt_id_type[i].id ); + break; + } + } + } + if( codec ) { pes->codec_param = codec->id; if ( codec->type == AVMEDIA_TYPE_VIDEO ) @@ -3955,7 +3990,7 @@ static int do_probe( hb_pes_stream_t *pes, hb_buffer_t *buf ) { pes->stream_kind = N; } - strncpy(pes->codec_name, fmt->name, 79); + strncpy(pes->codec_name, codec->name, 79); pes->codec_name[79] = 0; } else -- cgit v1.2.3