summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-10-26 22:40:34 +0000
committerRodeo <[email protected]>2012-10-26 22:40:34 +0000
commitf549e095e81420a26139f6b3b55d9b72c8360659 (patch)
tree9f667b36f2cf411c004caeeef54e5ea134c42a18 /libhb
parente84acc701fe25b366135e852c92648e1d0744bf3 (diff)
deca52: cleanup.
Some functions were called once per block, where once per frame was enough. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5027 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/deca52.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/libhb/deca52.c b/libhb/deca52.c
index 510e1ea88..922b88132 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -322,9 +322,13 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
/* Feed liba52 */
a52_frame(pv->state, pv->frame, &pv->flags, &pv->level, 0);
- /* If the user requested strong DRC (>1), adjust it.
- * If the user requested default DRC (1), leave it alone.
- * If the user requested no DRC (0), call a null function. */
+ /*
+ * If the user requested strong DRC (>1), adjust it.
+ * If the user requested default DRC (1), leave it alone.
+ * If the user requested no DRC (0), call a null function.
+ *
+ * a52_frame() resets the callback so it must be called for each frame.
+ */
if (pv->dynamic_range_compression > 1.0)
{
a52_dynrng(pv->state, dynrng_call, &pv->dynamic_range_compression);
@@ -334,30 +338,48 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
a52_dynrng(pv->state, NULL, NULL);
}
- /* Update input channel layout and prepare remapping */
+ /*
+ * Update input channel layout, prepare remapping and downmixing
+ */
uint64_t new_layout = (acmod2layout[(pv->flags & A52_CHANNEL_MASK)] |
lfeon2layout[(pv->flags & A52_LFE) != 0]);
+
if (new_layout != pv->channel_layout)
{
pv->channel_layout = new_layout;
pv->nchannels = av_get_channel_layout_nb_channels(new_layout);
+ hb_audio_resample_set_channel_layout(pv->resample,
+ pv->channel_layout,
+ pv->nchannels);
hb_audio_remap_build_table(&hb_libav_chan_map, &hb_liba52_chan_map,
pv->channel_layout, pv->remap_table);
}
+ if (pv->use_mix_levels)
+ {
+ hb_audio_resample_set_mix_levels(pv->resample,
+ (double)pv->state->slev,
+ (double)pv->state->clev);
+ }
+ if (hb_audio_resample_update(pv->resample))
+ {
+ hb_log("deca52: hb_audio_resample_update() failed");
+ return NULL;
+ }
- /* 6 blocks per frame, 256 samples per block, pv->nchannels channels */
+ // 6 blocks per frame, 256 samples per block, pv->nchannels channels
flt = hb_buffer_init(1536 * pv->nchannels * sizeof(float));
+ // decode all blocks before downmixing
for (i = 0; i < 6; i++)
{
- sample_t *samples_in;
- float *samples_out;
+ float *samples_in, *samples_out;
a52_block(pv->state);
- samples_in = a52_samples(pv->state);
- samples_out = ((float*)flt->data) + 256 * pv->nchannels * i;
+ samples_in = (float*)a52_samples(pv->state);
+ samples_out = (float*)(flt->data +
+ (i * pv->nchannels * 256 * sizeof(float)));
- /* Planar -> interleaved, remap to Libav channel order */
+ // Planar -> interleaved, remap to Libav channel order
for (j = 0; j < 256; j++)
{
for (k = 0; k < pv->nchannels; k++)
@@ -367,21 +389,7 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
}
}
}
- hb_audio_resample_set_channel_layout(pv->resample,
- pv->channel_layout,
- pv->nchannels);
- if (pv->use_mix_levels)
- {
- hb_audio_resample_set_mix_levels(pv->resample,
- (double)pv->state->slev,
- (double)pv->state->clev);
- }
- if (hb_audio_resample_update(pv->resample))
- {
- hb_log("deca52: hb_audio_resample_update() failed");
- hb_buffer_close(&flt);
- return NULL;
- }
+
out = hb_audio_resample(pv->resample, (void*)flt->data, 1536);
hb_buffer_close(&flt);
}