aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/ac3enc_template.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/ac3enc_template.c')
-rw-r--r--libavcodec/ac3enc_template.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c
index d88fa225a1..0547165aaf 100644
--- a/libavcodec/ac3enc_template.c
+++ b/libavcodec/ac3enc_template.c
@@ -31,6 +31,26 @@
#include "ac3enc.h"
+int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s)
+{
+ int ch;
+
+ FF_ALLOC_OR_GOTO(s->avctx, s->windowed_samples, AC3_WINDOW_SIZE *
+ sizeof(*s->windowed_samples), alloc_fail);
+ FF_ALLOC_OR_GOTO(s->avctx, s->planar_samples, s->channels * sizeof(*s->planar_samples),
+ alloc_fail);
+ for (ch = 0; ch < s->channels; ch++) {
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->planar_samples[ch],
+ (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples),
+ alloc_fail);
+ }
+
+ return 0;
+alloc_fail:
+ return AVERROR(ENOMEM);
+}
+
+
/**
* Deinterleave input samples.
* Channels are reordered from Libav's default order to AC-3 order.