[FFmpeg-devel] [PATCH] ac3dec: avoid pointless alloc and indirection for input_buffer
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Thu Mar 24 21:29:27 CET 2011
Since we now always allocate it, it can simply be made part of the context
instead.
---
libavcodec/ac3dec.c | 10 ----------
libavcodec/ac3dec.h | 5 ++++-
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 7f12d9c..d4e36c1 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -37,9 +37,6 @@
#include "ac3dec_data.h"
#include "kbdwin.h"
-/** Large enough for maximum possible frame size when the specification limit is ignored */
-#define AC3_FRAME_BUFFER_SIZE 32768
-
/**
* table for ungrouping 3 values in 7 bits.
* used for exponents and bap=2 mantissas
@@ -208,11 +205,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
}
s->downmixed = 1;
- /* allocate context input buffer */
- s->input_buffer = av_mallocz(AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!s->input_buffer)
- return AVERROR(ENOMEM);
-
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
return 0;
}
@@ -1425,8 +1417,6 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
ff_mdct_end(&s->imdct_512);
ff_mdct_end(&s->imdct_256);
- av_freep(&s->input_buffer);
-
return 0;
}
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index a5b1111..239fb1b 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -66,10 +66,13 @@
#define SPX_MAX_BANDS 17
+/** Large enough for maximum possible frame size when the specification limit is ignored */
+#define AC3_FRAME_BUFFER_SIZE 32768
+
typedef struct {
AVCodecContext *avctx; ///< parent context
GetBitContext gbc; ///< bitstream reader
- uint8_t *input_buffer; ///< temp buffer to prevent overread
+ uint8_t input_buffer[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
///@defgroup bsi bit stream information
///@{
--
1.7.4.1
More information about the ffmpeg-devel
mailing list