diff options
author | jstebbins <[email protected]> | 2011-10-15 21:32:20 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2011-10-15 21:32:20 +0000 |
commit | 0646bd60a8f672a003195e1c83ebbcb08d05aa99 (patch) | |
tree | 7a0655dddf26d2a5463f6ea59a0e6e802119e867 /libhb | |
parent | e3cbf2a342b7093d0b0b1720d3b3c933c3a4fa69 (diff) |
bump Libav from v0.7.1 to v0.7-1241-g5f3fb59
Fixes VC-1 decode issue
Adds partial support for interlaced VC-1 decode
Adds ProRes decoder
Fixes ac3 encoder dolby flag
Fixes DCA frame size setting (delete patch A04)
Fixes VC-1 repeat field processing (delete patch A05)
Numerous other bug fixes and enhancements
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4291 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/common.c | 1 | ||||
-rw-r--r-- | libhb/decavcodec.c | 15 | ||||
-rw-r--r-- | libhb/encavcodec.c | 23 | ||||
-rw-r--r-- | libhb/encavcodecaudio.c | 21 | ||||
-rw-r--r-- | libhb/hb.c | 41 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 4 | ||||
-rw-r--r-- | libhb/mcdeint.c | 5 | ||||
-rw-r--r-- | libhb/stream.c | 2 | ||||
-rw-r--r-- | libhb/sync.c | 2 |
9 files changed, 53 insertions, 61 deletions
diff --git a/libhb/common.c b/libhb/common.c index 4620602a7..cbf4ae65d 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -682,6 +682,7 @@ int hb_get_best_mixdown( uint32_t codec, int layout, int mixdown ) switch (codec) { case HB_ACODEC_LAME: + case HB_ACODEC_FFAAC: best_mixdown = HB_AMIXDOWN_DOLBYPLII; break; diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index ce459d6e5..28498273c 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -188,7 +188,7 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job ) if ( pv->title->opaque_priv ) { AVFormatContext *ic = (AVFormatContext*)pv->title->opaque_priv; - pv->context = avcodec_alloc_context(); + pv->context = avcodec_alloc_context3(codec); avcodec_copy_context( pv->context, ic->streams[w->audio->id]->codec); hb_ff_set_sample_fmt( pv->context, codec ); } @@ -199,7 +199,7 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job ) pv->context = avcodec_alloc_context3(codec); hb_ff_set_sample_fmt( pv->context, codec ); } - if ( hb_avcodec_open( pv->context, codec, 0 ) ) + if ( hb_avcodec_open( pv->context, codec, NULL, 0 ) ) { hb_log( "decavcodecaInit: avcodec_open failed" ); return 1; @@ -419,7 +419,7 @@ static int decavcodecaBSInfo( hb_work_object_t *w, const hb_buffer_t *buf, AVCodecParserContext *parser = av_parser_init( codec->id ); AVCodecContext *context = avcodec_alloc_context3(codec); hb_ff_set_sample_fmt( context, codec ); - if ( hb_avcodec_open( context, codec, 0 ) ) + if ( hb_avcodec_open( context, codec, NULL, 0 ) ) { return -1; } @@ -988,13 +988,13 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job ) hb_log( "decavcodecvInit: failed to find codec for id (%d)", w->codec_param ); return 1; } - pv->context = avcodec_alloc_context(); + pv->context = avcodec_alloc_context3(codec); avcodec_copy_context( pv->context, ic->streams[pv->title->video_id]->codec); pv->context->workaround_bugs = FF_BUG_AUTODETECT; pv->context->error_recognition = 1; pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK; - if ( hb_avcodec_open( pv->context, codec, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) ) + if ( hb_avcodec_open( pv->context, codec, NULL, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) ) { hb_log( "decavcodecvInit: avcodec_open failed" ); return 1; @@ -1010,8 +1010,9 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job ) } else { + AVCodec *codec = avcodec_find_decoder( w->codec_param ); pv->parser = av_parser_init( w->codec_param ); - pv->context = avcodec_alloc_context2( AVMEDIA_TYPE_VIDEO ); + pv->context = avcodec_alloc_context3( codec ); pv->context->workaround_bugs = FF_BUG_AUTODETECT; pv->context->error_recognition = 1; pv->context->error_concealment = FF_EC_GUESS_MVS|FF_EC_DEBLOCK; @@ -1155,7 +1156,7 @@ static int decavcodecvWork( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_OK; } // disable threaded decoding for scan, can cause crashes - if ( hb_avcodec_open( pv->context, codec, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) ) + if ( hb_avcodec_open( pv->context, codec, NULL, pv->job ? HB_FFMPEG_THREADS_AUTO : 0 ) ) { hb_log( "decavcodecvWork: avcodec_open failed" ); *buf_out = hb_buffer_init( 0 );; diff --git a/libhb/encavcodec.c b/libhb/encavcodec.c index 965752aa9..a3164f4a8 100644 --- a/libhb/encavcodec.c +++ b/libhb/encavcodec.c @@ -167,6 +167,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) the left side of the equals sign in "name" and the right side into "value." Then you hand those strings off to avutil for interpretation. */ + AVDictionary *av_opts = NULL; if( job->advanced_opts != NULL && *job->advanced_opts != '\0' ) { char *opts, *opts_start; @@ -179,7 +180,6 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) { char *name = opts; char *value; - int ret; opts += strcspn( opts, ":" ); if( *opts ) @@ -196,15 +196,7 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) } /* Here's where the strings are passed to avutil for parsing. */ - ret = hb_av_set_string( context, codec, name, value ); - - /* Let avutil sanity check the options for us*/ - if( ret == AVERROR_OPTION_NOT_FOUND ) - hb_log( "avcodec options: Unknown option %s", name ); - - if( ret == AVERROR(EINVAL) ) - hb_log( "avcodec options: Bad argument %s=%s", - name, value ? value : "(null)" ); + av_dict_set( &av_opts, name, value, 0 ); } } free(opts_start); @@ -282,10 +274,19 @@ int encavcodecInit( hb_work_object_t * w, hb_job_t * job ) } } - if( hb_avcodec_open( context, codec, 0 ) ) + if( hb_avcodec_open( context, codec, &av_opts, 0 ) ) { hb_log( "encavcodecInit: avcodec_open failed" ); } + // avcodec_open populates the opts dictionary with the + // things it didn't recognize. + AVDictionaryEntry *t = NULL; + while( ( t = av_dict_get( av_opts, "", t, AV_DICT_IGNORE_SUFFIX ) ) ) + { + hb_log( "encavcodecInit: Unknown avcodec option %s", t->key ); + } + av_dict_free( &av_opts ); + pv->context = context; job->areBframes = 0; diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c index cf27f0405..6645d22dc 100644 --- a/libhb/encavcodecaudio.c +++ b/libhb/encavcodecaudio.c @@ -58,16 +58,10 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) } context = avcodec_alloc_context3(codec); + AVDictionary *av_opts = NULL; if ( w->codec_param == CODEC_ID_AAC ) { - int ret = hb_av_set_string( context, codec, "stereo_mode", "ms_off" ); - /* Let avutil sanity check the options for us*/ - if( ret == AVERROR_OPTION_NOT_FOUND ) - hb_log( "avcodec options: Unknown option %s", "stereo_mode" ); - - if( ret == AVERROR(EINVAL) ) - hb_log( "avcodec options: Bad argument %s=%s", - "stereo_mode", "ms_off" ? "ms_off" : "(null)" ); + av_dict_set( &av_opts, "stereo_mode", "ms_off", 0 ); } context->channel_layout = AV_CH_LAYOUT_STEREO; @@ -111,11 +105,20 @@ static int encavcodecaInit( hb_work_object_t * w, hb_job_t * job ) // Try to set format to float. Fallback to whatever is supported. hb_ff_set_sample_fmt( context, codec ); - if( hb_avcodec_open( context, codec, 0 ) ) + if( hb_avcodec_open( context, codec, &av_opts, 0 ) ) { hb_log( "encavcodecaInit: avcodec_open failed" ); return 1; } + // avcodec_open populates the opts dictionary with the + // things it didn't recognize. + AVDictionaryEntry *t = NULL; + while( ( t = av_dict_get( av_opts, "", t, AV_DICT_IGNORE_SUFFIX ) ) ) + { + hb_log( "encavcodecaInit: Unknown avcodec option %s", t->key ); + } + av_dict_free( &av_opts ); + pv->context = context; audio->config.out.samples_per_frame = pv->samples_per_frame = context->frame_size; diff --git a/libhb/hb.c b/libhb/hb.c index 697c68c7a..f5c93de4d 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -99,7 +99,7 @@ void hb_avcodec_init() av_register_all(); } -int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, int thread_count) +int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, AVDictionary **av_opts, int thread_count) { int ret; @@ -116,7 +116,7 @@ int hb_avcodec_open(AVCodecContext *avctx, AVCodec *codec, int thread_count) avctx->thread_count = 1; } - ret = avcodec_open(avctx, codec); + ret = avcodec_open2(avctx, codec, av_opts); return ret; } @@ -127,20 +127,6 @@ int hb_avcodec_close(AVCodecContext *avctx) return ret; } -int hb_av_set_string( AVCodecContext *c, AVCodec *codec, const char *name, const char *val ) -{ - void * priv_context = NULL; - - if ( c && codec && codec->priv_class && c->priv_data ) - priv_context = c->priv_data; - - int ret = av_set_string3( c, name, val, 1, NULL ); - if ( ret == AVERROR_OPTION_NOT_FOUND && priv_context ) - ret = av_set_string3( priv_context, name, val, 1, NULL ); - - return ret; -} - static int handle_jpeg(enum PixelFormat *format) { switch (*format) { @@ -166,17 +152,19 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat, srcRange = handle_jpeg(&srcFormat); dstRange = handle_jpeg(&dstFormat); + /* enable this when implemented in Libav flags |= SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP; + */ - av_set_int(ctx, "srcw", srcW); - av_set_int(ctx, "srch", srcH); - av_set_int(ctx, "src_range", srcRange); - av_set_int(ctx, "src_format", srcFormat); - av_set_int(ctx, "dstw", dstW); - av_set_int(ctx, "dsth", dstH); - av_set_int(ctx, "dst_range", dstRange); - av_set_int(ctx, "dst_format", dstFormat); - av_set_int(ctx, "sws_flags", flags); + av_opt_set_int(ctx, "srcw", srcW, 0); + av_opt_set_int(ctx, "srch", srcH, 0); + av_opt_set_int(ctx, "src_range", srcRange, 0); + av_opt_set_int(ctx, "src_format", srcFormat, 0); + av_opt_set_int(ctx, "dstw", dstW, 0); + av_opt_set_int(ctx, "dsth", dstH, 0); + av_opt_set_int(ctx, "dst_range", dstRange, 0); + av_opt_set_int(ctx, "dst_format", dstFormat, 0); + av_opt_set_int(ctx, "sws_flags", flags, 0); sws_setColorspaceDetails( ctx, sws_getCoefficients( SWS_CS_DEFAULT ), // src colorspace @@ -544,8 +532,7 @@ hb_handle_t * hb_init_dl( int verbose, int update_check ) h->pause_lock = hb_lock_init(); /* libavcodec */ - avcodec_init(); - avcodec_register_all(); + hb_avcodec_init(); /* Start library thread */ hb_log( "hb_init: starting libhb thread" ); diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index f1ea4a704..53cdee87a 100644 --- a/libhb/hbffmpeg.h +++ b/libhb/hbffmpeg.h @@ -5,12 +5,13 @@ #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavutil/opt.h" +#include "libavutil/mathematics.h" #include "libswscale/swscale.h" #define HB_FFMPEG_THREADS_AUTO (-1) // let hb_avcodec_open decide thread_count void hb_avcodec_init(void); -int hb_avcodec_open( AVCodecContext *, struct AVCodec *, int thread_count ); +int hb_avcodec_open( AVCodecContext *, struct AVCodec *, AVDictionary **av_opts, int thread_count ); int hb_avcodec_close( AVCodecContext * ); int hb_ff_layout_xlat(int64_t ff_layout, int channels); struct SwsContext* @@ -19,4 +20,3 @@ hb_sws_get_context(int srcW, int srcH, enum PixelFormat srcFormat, int flags); void hb_ff_set_sample_fmt(AVCodecContext *context, AVCodec *codec); int hb_ff_dts_request_5point1( AVCodecContext *c ); -int hb_av_set_string( AVCodecContext *c, AVCodec *codec, const char *name, const char *val ); diff --git a/libhb/mcdeint.c b/libhb/mcdeint.c index 1c7138bd7..9e3d82371 100644 --- a/libhb/mcdeint.c +++ b/libhb/mcdeint.c @@ -37,7 +37,6 @@ void mcdeint_init( mcdeint_private_t * pv, /* Allocate mcdeint specific buffers */ if( pv->mcdeint_mode >= 0 ) { - avcodec_init(); avcodec_register_all(); AVCodec * enc = avcodec_find_encoder( CODEC_ID_SNOW ); @@ -47,7 +46,7 @@ void mcdeint_init( mcdeint_private_t * pv, { AVCodecContext * avctx_enc; - avctx_enc = pv->mcdeint_avctx_enc = avcodec_alloc_context(); + avctx_enc = pv->mcdeint_avctx_enc = avcodec_alloc_context3( enc ); avctx_enc->width = width; avctx_enc->height = height; @@ -76,7 +75,7 @@ void mcdeint_init( mcdeint_private_t * pv, avctx_enc->flags |= CODEC_FLAG_QPEL; } - hb_avcodec_open(avctx_enc, enc, 0); + hb_avcodec_open(avctx_enc, enc, NULL, 0); } pv->mcdeint_frame = avcodec_alloc_frame(); diff --git a/libhb/stream.c b/libhb/stream.c index 90f6a895b..a5401ec18 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -4763,7 +4763,7 @@ static int ffmpeg_open( hb_stream_t *stream, hb_title_t *title, int scan ) { return 0; } - if ( av_find_stream_info( info_ic ) < 0 ) + if ( avformat_find_stream_info( info_ic, NULL ) < 0 ) goto fail; title->opaque_priv = (void*)info_ic; diff --git a/libhb/sync.c b/libhb/sync.c index b1ec99619..6c1911b98 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -1174,7 +1174,7 @@ static void InitAudio( hb_job_t * job, hb_sync_common_t * common, int i ) c->channel_layout |= AV_CH_LOW_FREQUENCY; } - if( hb_avcodec_open( c, codec, 0 ) < 0 ) + if( hb_avcodec_open( c, codec, NULL, 0 ) < 0 ) { hb_log( "sync: avcodec_open failed" ); return; |