Commit 6e075dca authored by Reimar Döffinger's avatar Reimar Döffinger

ac3dec: avoid pointless alloc and indirection for input_buffer

Since we now always allocate it, it can simply be made part of the context
instead.
parent 6f73d5e8
...@@ -37,9 +37,6 @@ ...@@ -37,9 +37,6 @@
#include "ac3dec_data.h" #include "ac3dec_data.h"
#include "kbdwin.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. * table for ungrouping 3 values in 7 bits.
* used for exponents and bap=2 mantissas * used for exponents and bap=2 mantissas
...@@ -204,11 +201,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx) ...@@ -204,11 +201,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
} }
s->downmixed = 1; 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);
/* ffdshow custom code */ /* ffdshow custom code */
#if CONFIG_AUDIO_FLOAT #if CONFIG_AUDIO_FLOAT
avctx->sample_fmt = AV_SAMPLE_FMT_FLT; avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
...@@ -1441,8 +1433,6 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx) ...@@ -1441,8 +1433,6 @@ static av_cold int ac3_decode_end(AVCodecContext *avctx)
ff_mdct_end(&s->imdct_512); ff_mdct_end(&s->imdct_512);
ff_mdct_end(&s->imdct_256); ff_mdct_end(&s->imdct_256);
av_freep(&s->input_buffer);
return 0; return 0;
} }
......
...@@ -67,10 +67,12 @@ ...@@ -67,10 +67,12 @@
#define SPX_MAX_BANDS 17 #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 { typedef struct {
AVCodecContext *avctx; ///< parent context AVCodecContext *avctx; ///< parent context
GetBitContext gbc; ///< bitstream reader GetBitContext gbc; ///< bitstream reader
uint8_t *input_buffer; ///< temp buffer to prevent overread
///@defgroup bsi bit stream information ///@defgroup bsi bit stream information
///@{ ///@{
...@@ -205,6 +207,7 @@ typedef struct { ...@@ -205,6 +207,7 @@ typedef struct {
DECLARE_ALIGNED(16, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients DECLARE_ALIGNED(16, float, window)[AC3_BLOCK_SIZE]; ///< window coefficients
DECLARE_ALIGNED(16, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing DECLARE_ALIGNED(16, float, tmp_output)[AC3_BLOCK_SIZE]; ///< temporary storage for output before windowing
DECLARE_ALIGNED(16, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing DECLARE_ALIGNED(16, float, output)[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE]; ///< output after imdct transform and windowing
DECLARE_ALIGNED(16, uint8_t, input_buffer)[AC3_FRAME_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE]; ///< temp buffer to prevent overread
///@} ///@}
} AC3DecodeContext; } AC3DecodeContext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment