summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-10-26 23:03:45 +0000
committerRodeo <[email protected]>2012-10-26 23:03:45 +0000
commit0c0f58686e42484344fe2873dd639aae319f4835 (patch)
tree2659689ac93bc3702e0e40e79def86bebc4856cc
parenta71548f7c91eb6485394603c07bdcd75609c8412 (diff)
deca52: avoid repeated alloc/free by re-using a fixed-size buffer.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5029 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r--libhb/deca52.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/libhb/deca52.c b/libhb/deca52.c
index d605a8dd7..3a6e71e95 100644
--- a/libhb/deca52.c
+++ b/libhb/deca52.c
@@ -35,6 +35,7 @@ struct hb_work_private_s
hb_list_t *list;
const AVCRC *crc_table;
uint8_t frame[3840];
+ uint8_t buf[1536 * 6 * sizeof(float)]; // decoded samples (1 frame, 6 channels)
int nchannels;
int remap_table[6];
@@ -317,7 +318,6 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
else
{
int i, j, k;
- hb_buffer_t *flt;
/* Feed liba52 */
a52_frame(pv->state, pv->frame, &pv->flags, &pv->level, 0);
@@ -366,9 +366,6 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
return NULL;
}
- // 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++)
{
@@ -376,7 +373,7 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
a52_block(pv->state);
samples_in = (float*)a52_samples(pv->state);
- samples_out = (float*)(flt->data +
+ samples_out = (float*)(pv->buf +
(i * pv->nchannels * 256 * sizeof(float)));
// Planar -> interleaved, remap to Libav channel order
@@ -390,8 +387,7 @@ static hb_buffer_t* Decode(hb_work_object_t *w)
}
}
- out = hb_audio_resample(pv->resample, (void*)flt->data, 1536);
- hb_buffer_close(&flt);
+ out = hb_audio_resample(pv->resample, (void*)pv->buf, 1536);
}
if (out != NULL)