diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/audio_resample.c | 9 | ||||
-rw-r--r-- | libhb/audio_resample.h | 7 | ||||
-rw-r--r-- | libhb/deca52.c | 3 | ||||
-rw-r--r-- | libhb/decavcodec.c | 23 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 1 |
5 files changed, 40 insertions, 3 deletions
diff --git a/libhb/audio_resample.c b/libhb/audio_resample.c index 913186cc0..577c66dad 100644 --- a/libhb/audio_resample.c +++ b/libhb/audio_resample.c @@ -62,6 +62,7 @@ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat sample_fmt, // set default input characteristics resample->in.sample_fmt = resample->out.sample_fmt; resample->in.channel_layout = resample->out.channel_layout; + resample->in.lfe_mix_level = HB_MIXLEV_ZERO; resample->in.center_mix_level = HB_MIXLEV_DEFAULT; resample->in.surround_mix_level = HB_MIXLEV_DEFAULT; @@ -90,10 +91,12 @@ void hb_audio_resample_set_channel_layout(hb_audio_resample_t *resample, void hb_audio_resample_set_mix_levels(hb_audio_resample_t *resample, double surround_mix_level, - double center_mix_level) + double center_mix_level, + double lfe_mix_level) { if (resample != NULL) { + resample->in.lfe_mix_level = lfe_mix_level; resample->in.center_mix_level = center_mix_level; resample->in.surround_mix_level = surround_mix_level; } @@ -126,6 +129,7 @@ int hb_audio_resample_update(hb_audio_resample_t *resample) (resample->resample_needed && (resample->resample.sample_fmt != resample->in.sample_fmt || resample->resample.channel_layout != resample->in.channel_layout || + resample->resample.lfe_mix_level != resample->in.lfe_mix_level || resample->resample.center_mix_level != resample->in.center_mix_level || resample->resample.surround_mix_level != resample->in.surround_mix_level)); @@ -159,6 +163,8 @@ int hb_audio_resample_update(hb_audio_resample_t *resample) resample->in.sample_fmt, 0); av_opt_set_int(resample->avresample, "in_channel_layout", resample->in.channel_layout, 0); + av_opt_set_double(resample->avresample, "lfe_mix_level", + resample->in.lfe_mix_level, 0); av_opt_set_double(resample->avresample, "center_mix_level", resample->in.center_mix_level, 0); av_opt_set_double(resample->avresample, "surround_mix_level", @@ -179,6 +185,7 @@ int hb_audio_resample_update(hb_audio_resample_t *resample) resample->resample.channel_layout = resample->in.channel_layout; resample->resample.channels = av_get_channel_layout_nb_channels(resample->in.channel_layout); + resample->resample.lfe_mix_level = resample->in.lfe_mix_level; resample->resample.center_mix_level = resample->in.center_mix_level; resample->resample.surround_mix_level = resample->in.surround_mix_level; } diff --git a/libhb/audio_resample.h b/libhb/audio_resample.h index 9242d78a5..3b9c646ff 100644 --- a/libhb/audio_resample.h +++ b/libhb/audio_resample.h @@ -24,6 +24,8 @@ /* Default mix level for center and surround channels */ #define HB_MIXLEV_DEFAULT ((double)M_SQRT1_2) +/* Default mix level for LFE channel */ +#define HB_MIXLEV_ZERO ((double)0.0) typedef struct { @@ -36,6 +38,7 @@ typedef struct struct { uint64_t channel_layout; + double lfe_mix_level; double center_mix_level; double surround_mix_level; enum AVSampleFormat sample_fmt; @@ -45,6 +48,7 @@ typedef struct { int channels; uint64_t channel_layout; + double lfe_mix_level; double center_mix_level; double surround_mix_level; enum AVSampleFormat sample_fmt; @@ -81,7 +85,8 @@ void hb_audio_resample_set_channel_layout(hb_audio_resample_t *r void hb_audio_resample_set_mix_levels(hb_audio_resample_t *resample, double surround_mix_level, - double center_mix_level); + double center_mix_level, + double lfe_mix_level); void hb_audio_resample_set_sample_fmt(hb_audio_resample_t *resample, enum AVSampleFormat sample_fmt); diff --git a/libhb/deca52.c b/libhb/deca52.c index 925e824b2..d8bf497c2 100644 --- a/libhb/deca52.c +++ b/libhb/deca52.c @@ -391,7 +391,8 @@ static hb_buffer_t* Decode(hb_work_object_t *w) { hb_audio_resample_set_mix_levels(pv->resample, (double)pv->state->slev, - (double)pv->state->clev); + (double)pv->state->clev, + HB_MIXLEV_ZERO); } if (hb_audio_resample_update(pv->resample)) { diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 7409bc8db..c158bcf1b 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -2176,6 +2176,29 @@ static void decodeAudio(hb_audio_t *audio, hb_work_private_t *pv, uint8_t *data, } else { + AVFrameSideData *side_data; + if ((side_data = + av_frame_get_side_data(pv->frame, + AV_FRAME_DATA_DOWNMIX_INFO)) != NULL) + { + double surround_mix_level, center_mix_level; + AVDownmixInfo *downmix_info = (AVDownmixInfo*)side_data->data; + if (audio->config.out.mixdown == HB_AMIXDOWN_DOLBY || + audio->config.out.mixdown == HB_AMIXDOWN_DOLBYPLII) + { + surround_mix_level = downmix_info->surround_mix_level_ltrt; + center_mix_level = downmix_info->center_mix_level_ltrt; + } + else + { + surround_mix_level = downmix_info->surround_mix_level; + center_mix_level = downmix_info->center_mix_level; + } + hb_audio_resample_set_mix_levels(pv->resample, + surround_mix_level, + center_mix_level, + downmix_info->lfe_mix_level); + } hb_audio_resample_set_channel_layout(pv->resample, pv->frame->channel_layout); hb_audio_resample_set_sample_fmt(pv->resample, diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index b1379d006..218ac34a5 100644 --- a/libhb/hbffmpeg.h +++ b/libhb/hbffmpeg.h @@ -14,6 +14,7 @@ #include "libavutil/mathematics.h" #include "libavutil/opt.h" #include "libavutil/avutil.h" +#include "libavutil/downmix_info.h" #include "libswscale/swscale.h" #include "libavresample/avresample.h" #include "common.h" |