diff options
author | Rodeo <[email protected]> | 2014-01-25 23:24:48 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2014-01-25 23:24:48 +0000 |
commit | d7ad9c9682d83dc8f59bd6ff86d3ec422c1f6adb (patch) | |
tree | 2dffccb32b266858c1d52f3d63463e83c049937a /libhb/decavcodec.c | |
parent | ebf885ce8a75dd392e2acab9a8a0e29032e05f71 (diff) |
decavcodec: DRC support.
Adds DRC support for E-AC-3 audio (as well as any future libavcodec decoders with DRC support).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5995 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/decavcodec.c')
-rw-r--r-- | libhb/decavcodec.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 5a4b0513c..1e760583b 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -360,12 +360,54 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job ) AVDictionary * av_opts = NULL; av_dict_set( &av_opts, "refcounted_frames", "1", 0 ); + // Dynamic Range Compression + if (w->audio->config.out.dynamic_range_compression >= 0.0f && + hb_audio_can_apply_drc(w->audio->config.in.codec, + w->audio->config.in.codec_param, 0)) + { + float drc_scale_max = 1.0f; + /* + * avcodec_open will fail if the value for any of the options is out of + * range, so assume a conservative maximum of 1 and try to determine the + * option's actual upper limit. + */ + if (codec != NULL && codec->priv_class != NULL) + { + const AVOption *opt; + opt = av_opt_find2((void*)&codec->priv_class, "drc_scale", NULL, + AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_AUDIO_PARAM, + AV_OPT_SEARCH_FAKE_OBJ, NULL); + if (opt != NULL) + { + drc_scale_max = opt->max; + } + } + if (w->audio->config.out.dynamic_range_compression > drc_scale_max) + { + hb_log("decavcodecaInit: track %d, sanitizing out-of-range DRC %.2f to %.2f", + w->audio->config.out.track, + w->audio->config.out.dynamic_range_compression, drc_scale_max); + w->audio->config.out.dynamic_range_compression = drc_scale_max; + } + + char drc_scale[5]; // "?.??\n" + snprintf(drc_scale, sizeof(drc_scale), "%.2f", + w->audio->config.out.dynamic_range_compression); + av_dict_set(&av_opts, "drc_scale", drc_scale, 0); + } + if (hb_avcodec_open(pv->context, codec, &av_opts, 0)) { av_dict_free( &av_opts ); hb_log("decavcodecaInit: avcodec_open failed"); return 1; } + // avcodec_open populates av_opts with the things it didn't recognize. + AVDictionaryEntry *t = NULL; + while ((t = av_dict_get(av_opts, "", t, AV_DICT_IGNORE_SUFFIX)) != NULL) + { + hb_log("decavcodecaInit: unknown option '%s'", t->key); + } av_dict_free( &av_opts ); pv->frame = av_frame_alloc(); |