avcodec/ac3enc: Avoid allocation for windowed_samples
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
35ae44c615
commit
3b93b1af13
@ -2184,7 +2184,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
|
||||
AC3EncodeContext *s = avctx->priv_data;
|
||||
|
||||
av_freep(&s->mdct_window);
|
||||
av_freep(&s->windowed_samples);
|
||||
if (s->planar_samples)
|
||||
for (ch = 0; ch < s->channels; ch++)
|
||||
av_freep(&s->planar_samples[ch]);
|
||||
@ -2459,9 +2458,6 @@ static av_cold int allocate_buffers(AC3EncodeContext *s)
|
||||
int total_coefs = AC3_MAX_COEFS * channel_blocks;
|
||||
const unsigned sampletype_size = SAMPLETYPE_SIZE(s);
|
||||
|
||||
if (!(s->windowed_samples = av_malloc(sampletype_size * AC3_WINDOW_SIZE)))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
if (!FF_ALLOCZ_TYPED_ARRAY(s->planar_samples, s->channels))
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libavutil/mem_internal.h"
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/tx.h"
|
||||
|
||||
@ -232,7 +233,6 @@ typedef struct AC3EncodeContext {
|
||||
int frame_bits; ///< all frame bits except exponents and mantissas
|
||||
int exponent_bits; ///< number of bits used for exponents
|
||||
|
||||
void *windowed_samples;
|
||||
uint8_t **planar_samples;
|
||||
uint8_t *bap_buffer;
|
||||
uint8_t *bap1_buffer;
|
||||
@ -259,6 +259,11 @@ typedef struct AC3EncodeContext {
|
||||
|
||||
/* AC-3 vs. E-AC-3 function pointers */
|
||||
void (*output_frame_header)(struct AC3EncodeContext *s);
|
||||
|
||||
union {
|
||||
DECLARE_ALIGNED(32, float, windowed_samples_float)[AC3_WINDOW_SIZE];
|
||||
DECLARE_ALIGNED(32, int32_t, windowed_samples_fixed)[AC3_WINDOW_SIZE];
|
||||
};
|
||||
} AC3EncodeContext;
|
||||
|
||||
extern const AVChannelLayout ff_ac3_ch_layouts[19];
|
||||
|
@ -37,6 +37,11 @@
|
||||
#include "ac3enc.h"
|
||||
#include "eac3enc.h"
|
||||
|
||||
#if AC3ENC_FLOAT
|
||||
#define RENAME(element) element ## _float
|
||||
#else
|
||||
#define RENAME(element) element ## _fixed
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Apply the MDCT to input samples to generate frequency coefficients.
|
||||
@ -51,15 +56,16 @@ static void apply_mdct(AC3EncodeContext *s)
|
||||
for (blk = 0; blk < s->num_blocks; blk++) {
|
||||
AC3Block *block = &s->blocks[blk];
|
||||
const SampleType *input_samples = (SampleType*)s->planar_samples[ch] + blk * AC3_BLOCK_SIZE;
|
||||
SampleType *windowed_samples = s->RENAME(windowed_samples);
|
||||
|
||||
s->fdsp->vector_fmul(s->windowed_samples, input_samples,
|
||||
s->fdsp->vector_fmul(windowed_samples, input_samples,
|
||||
s->mdct_window, AC3_BLOCK_SIZE);
|
||||
s->fdsp->vector_fmul_reverse((SampleType*)s->windowed_samples + AC3_BLOCK_SIZE,
|
||||
s->fdsp->vector_fmul_reverse(windowed_samples + AC3_BLOCK_SIZE,
|
||||
&input_samples[AC3_BLOCK_SIZE],
|
||||
s->mdct_window, AC3_BLOCK_SIZE);
|
||||
|
||||
s->tx_fn(s->tx, block->mdct_coef[ch+1],
|
||||
s->windowed_samples, sizeof(float));
|
||||
windowed_samples, sizeof(*windowed_samples));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user