summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2011-11-06 01:43:21 +0000
committerjstebbins <[email protected]>2011-11-06 01:43:21 +0000
commitd986524c71c2e41ce329e9dd5f6c78cb3d6e4de2 (patch)
treef1868de223c66ea0179537b498da3645ccd4efbb /libhb
parent4ec40322ea7ac15f645a6a056da99b43d6d2ac12 (diff)
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
Diffstat (limited to 'libhb')
-rw-r--r--libhb/hb.c7
-rw-r--r--libhb/stream.c39
2 files changed, 39 insertions, 7 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index f5c93de4d..0e3e9e572 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -64,20 +64,17 @@ int hb_process_initialized = 0;
static void thread_func( void * );
hb_title_t * hb_get_title_by_index( hb_handle_t *, int );
-hb_lock_t *hb_avcodec_lock;
static int ff_lockmgr_cb(void **mutex, enum AVLockOp op)
{
switch ( op )
{
case AV_LOCK_CREATE:
{
- hb_avcodec_lock = hb_lock_init();
- *mutex = hb_avcodec_lock;
+ *mutex = hb_lock_init();
} break;
case AV_LOCK_DESTROY:
{
- hb_lock_close( &hb_avcodec_lock );
- *mutex = NULL;
+ hb_lock_close( (hb_lock_t**)mutex );
} break;
case AV_LOCK_OBTAIN:
{
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