summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-08-27 22:00:28 +0000
committerRodeo <[email protected]>2012-08-27 22:00:28 +0000
commit33aaba22f0a5a8290ba75809b522e4293822296b (patch)
treebd3cb639b1612aa8ee4dcf47db1db5f7d981935d
parentd5cd2171f6bd69ec44d4568926728b890f7d1f97 (diff)
Move mixdown-> channel_layout/matrix_encoding translation to hb_audio_resample_init().
Unlike hb_audio_remap, hb_audio_resample will never be used in situations where we don't have a mixdown. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4923 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/audio_resample.c42
-rw-r--r--libhb/audio_resample.h10
-rw-r--r--libhb/deca52.c8
-rw-r--r--libhb/decavcodec.c9
-rw-r--r--libhb/declpcm.c8
-rw-r--r--libhb/encavcodecaudio.c3
6 files changed, 44 insertions, 36 deletions
diff --git a/libhb/audio_resample.c b/libhb/audio_resample.c
index 1e5e10556..44f2a0144 100644
--- a/libhb/audio_resample.c
+++ b/libhb/audio_resample.c
@@ -11,9 +11,8 @@
#include "hbffmpeg.h"
#include "audio_resample.h"
-hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat output_sample_fmt,
- uint64_t output_channel_layout,
- enum AVMatrixEncoding matrix_encoding,
+hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat sample_fmt,
+ int hb_amixdown, int do_remix,
int normalize_mix_level)
{
hb_audio_resample_t *resample = malloc(sizeof(hb_audio_resample_t));
@@ -23,22 +22,31 @@ hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat output_sample_fm
return NULL;
}
- resample->out.sample_fmt = output_sample_fmt;
- resample->out.sample_size =
- av_get_bytes_per_sample(output_sample_fmt);
- resample->out.channel_layout = output_channel_layout;
- resample->out.channels =
- av_get_channel_layout_nb_channels(output_channel_layout);
+ // convert mixdown to channel_layout/matrix_encoding combo
+ int channels, matrix_encoding;
+ uint64_t channel_layout = hb_ff_mixdown_xlat(hb_amixdown, &matrix_encoding);
+ channels = av_get_channel_layout_nb_channels(channel_layout);
+
+ // requested channel_layout
+ resample->out.channels = channels;
+ resample->out.channel_layout = channel_layout;
resample->out.matrix_encoding = matrix_encoding;
resample->out.normalize_mix_level = normalize_mix_level;
- resample->resample_needed = 0;
- resample->avresample = NULL;
+
+ // requested sample_fmt
+ resample->out.sample_fmt = sample_fmt;
+ resample->out.sample_size = av_get_bytes_per_sample(sample_fmt);
// set default input characteristics
- resample->in.sample_fmt = resample->out.sample_fmt;
- resample->in.channel_layout = resample->out.channel_layout;
- resample->in.center_mix_level = HB_MIXLEV_DEFAULT;
- resample->in.surround_mix_level = HB_MIXLEV_DEFAULT;
+ resample->in.sample_fmt = resample->out.sample_fmt;
+ resample->in.channel_layout = resample->out.channel_layout;
+ resample->in.center_mix_level = HB_MIXLEV_DEFAULT;
+ resample->in.surround_mix_level = HB_MIXLEV_DEFAULT;
+
+ // by default, no conversion needed
+ resample->resample_needed = 0;
+ resample->avresample = NULL;
+ resample->do_remix = !!do_remix;
return resample;
}
@@ -47,7 +55,7 @@ void hb_audio_resample_set_channel_layout(hb_audio_resample_t *resample,
uint64_t channel_layout,
int channels)
{
- if (resample != NULL)
+ if (resample != NULL && resample->do_remix)
{
channel_layout = hb_ff_layout_xlat(channel_layout, channels);
if (channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
@@ -63,7 +71,7 @@ void hb_audio_resample_set_mix_levels(hb_audio_resample_t *resample,
double surround_mix_level,
double center_mix_level)
{
- if (resample != NULL)
+ if (resample != NULL && resample->do_remix)
{
resample->in.center_mix_level = center_mix_level;
resample->in.surround_mix_level = surround_mix_level;
diff --git a/libhb/audio_resample.h b/libhb/audio_resample.h
index c853fc2e2..3a01d8696 100644
--- a/libhb/audio_resample.h
+++ b/libhb/audio_resample.h
@@ -27,6 +27,7 @@
typedef struct
{
+ int do_remix;
int resample_needed;
AVAudioResampleContext *avresample;
@@ -59,14 +60,15 @@ typedef struct
} hb_audio_resample_t;
/* Initialize an hb_audio_resample_t for converting audio to the requested
- * sample_fmt and channel_layout, using the specified matrix_encoding.
+ * sample_fmt and mixdown.
*
* Also sets the default audio input characteristics, so that they are the same
* as the output characteristics (no conversion needed).
+ *
+ * If do_remix is 0, it will be assumed that any remixing was *already* done.
*/
-hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat output_sample_fmt,
- uint64_t output_channel_layout,
- enum AVMatrixEncoding matrix_encoding,
+hb_audio_resample_t* hb_audio_resample_init(enum AVSampleFormat sample_fmt,
+ int hb_amixdown, int do_remix,
int normalize_mix_level);
/* The following functions set the audio input characteristics.
diff --git a/libhb/deca52.c b/libhb/deca52.c
index 9ad603861..66e936dd2 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -139,10 +139,10 @@ static int deca52Init(hb_work_object_t *w, hb_job_t *job)
pv->dynamic_range_compression =
audio->config.out.dynamic_range_compression;
- int mode;
- uint64_t layout = hb_ff_mixdown_xlat(audio->config.out.mixdown, &mode);
- pv->resample = hb_audio_resample_init(AV_SAMPLE_FMT_FLT, layout, mode,
- audio->config.out.normalize_mix_level);
+ pv->resample =
+ hb_audio_resample_init(AV_SAMPLE_FMT_FLT,
+ audio->config.out.mixdown, 1,
+ audio->config.out.normalize_mix_level);
if (pv->resample == NULL)
{
hb_error("deca52Init: hb_audio_resample_init() failed");
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c
index 4dc1e7388..a5312273d 100644
--- a/libhb/decavcodec.c
+++ b/libhb/decavcodec.c
@@ -189,11 +189,10 @@ static int decavcodecaInit( hb_work_object_t * w, hb_job_t * job )
/* Downmixing & sample_fmt conversion */
if (!(w->audio->config.out.codec & HB_ACODEC_PASS_FLAG))
{
- int mode;
- uint64_t layout = hb_ff_mixdown_xlat(w->audio->config.out.mixdown,
- &mode);
- pv->resample = hb_audio_resample_init(AV_SAMPLE_FMT_FLT, layout, mode,
- w->audio->config.out.normalize_mix_level);
+ pv->resample =
+ hb_audio_resample_init(AV_SAMPLE_FMT_FLT,
+ w->audio->config.out.mixdown, 1,
+ w->audio->config.out.normalize_mix_level);
if (pv->resample == NULL)
{
hb_error("decavcodecaInit: hb_audio_resample_init() failed");
diff --git a/libhb/declpcm.c b/libhb/declpcm.c
index 85a47c313..0cb5726a5 100644
--- a/libhb/declpcm.c
+++ b/libhb/declpcm.c
@@ -162,10 +162,10 @@ static int declpcmInit( hb_work_object_t * w, hb_job_t * job )
w->private_data = pv;
pv->job = job;
- int mode;
- uint64_t layout = hb_ff_mixdown_xlat(w->audio->config.out.mixdown, &mode);
- pv->resample = hb_audio_resample_init(AV_SAMPLE_FMT_FLT, layout, mode,
- w->audio->config.out.normalize_mix_level);
+ pv->resample =
+ hb_audio_resample_init(AV_SAMPLE_FMT_FLT,
+ w->audio->config.out.mixdown, 1,
+ w->audio->config.out.normalize_mix_level);
if (pv->resample == NULL)
{
hb_error("declpcmInit: hb_audio_resample_init() failed");
diff --git a/libhb/encavcodecaudio.c b/libhb/encavcodecaudio.c
index 3a0af64d2..67f4d23d5 100644
--- a/libhb/encavcodecaudio.c
+++ b/libhb/encavcodecaudio.c
@@ -118,8 +118,7 @@ static int encavcodecaInit(hb_work_object_t *w, hb_job_t *job)
// sample_fmt conversion
pv->resample = hb_audio_resample_init(context->sample_fmt,
- context->channel_layout,
- AV_MATRIX_ENCODING_NONE, 0);
+ audio->config.out.mixdown, 0, 0);
hb_audio_resample_set_sample_fmt(pv->resample, AV_SAMPLE_FMT_FLT);
if (hb_audio_resample_update(pv->resample))
{