diff options
author | Rodeo <[email protected]> | 2012-08-02 21:43:22 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2012-08-02 21:43:22 +0000 |
commit | b3717d369763d620d548f224daeba5a7503fa972 (patch) | |
tree | 4742e9b49e03db2b1c558e10f40c2c821528e8f5 /libhb/audio_resample.c | |
parent | ad257c9dac38fe3f7502b1058247b4458465c0a8 (diff) |
Use hb_audio_resample for downmixing AC3 sources. DRC is still applied by liba52.
Add support for center & surround mix levels to hb_audio_resample.
This allows us to support upmixing all audio sources. For sources that have at least 2 front and one back or side channel(s), allow upmixing to 5.1:
3.0/3.1 (2 front and 1 back channels)
4.0/4.1 (3 front and 1 back channels)
4.0/4.1 (2 front and 2 side channels)
5.0 (3 front and 2 side channels)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4885 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/audio_resample.c')
-rw-r--r-- | libhb/audio_resample.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/libhb/audio_resample.c b/libhb/audio_resample.c index ea09b38a2..072351192 100644 --- a/libhb/audio_resample.c +++ b/libhb/audio_resample.c @@ -18,7 +18,10 @@ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat output_sample_fm { hb_audio_resample_t *resample = malloc(sizeof(hb_audio_resample_t)); if (resample == NULL) + { + hb_error("hb_audio_resample_init: failed to allocate resample"); return NULL; + } resample->out.sample_fmt = output_sample_fmt; resample->out.sample_size = @@ -37,6 +40,8 @@ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat output_sample_fm int hb_audio_resample_update(hb_audio_resample_t *resample, enum AVSampleFormat new_sample_fmt, uint64_t new_channel_layout, + double new_surroundmixlev, + double new_centermixlev, int new_channels) { if (resample == NULL) @@ -55,7 +60,9 @@ int hb_audio_resample_update(hb_audio_resample_t *resample, int resample_changed = (resample->resample_needed && (resample->in.sample_fmt != new_sample_fmt || - resample->in.channel_layout != new_channel_layout)); + resample->in.channel_layout != new_channel_layout || + resample->in.center_mix_level != new_centermixlev || + resample->in.surround_mix_level != new_surroundmixlev)); if (resample_changed || (resample->resample_needed && resample->avresample == NULL)) @@ -87,6 +94,10 @@ int hb_audio_resample_update(hb_audio_resample_t *resample, new_sample_fmt, 0); av_opt_set_int(resample->avresample, "in_channel_layout", new_channel_layout, 0); + av_opt_set_double(resample->avresample, "center_mix_level", + new_centermixlev, 0); + av_opt_set_double(resample->avresample, "surround_mix_level", + new_surroundmixlev, 0); if (avresample_open(resample->avresample) < 0) { @@ -96,8 +107,10 @@ int hb_audio_resample_update(hb_audio_resample_t *resample, return 1; } - resample->in.sample_fmt = new_sample_fmt; - resample->in.channel_layout = new_channel_layout; + resample->in.sample_fmt = new_sample_fmt; + resample->in.channel_layout = new_channel_layout; + resample->in.center_mix_level = new_centermixlev; + resample->in.surround_mix_level = new_surroundmixlev; } return 0; |