@ -31,8 +31,6 @@
# include <stdint.h>
# include "libavutil/attributes.h"
# include "libavutil/internal.h"
# include "libavutil/mem.h"
# include "libavutil/mem_internal.h"
# include "audiodsp.h"
@ -40,23 +38,6 @@
# include "eac3enc.h"
static int allocate_sample_buffers ( AC3EncodeContext * s )
{
int ch ;
if ( ! FF_ALLOC_TYPED_ARRAY ( s - > windowed_samples , AC3_WINDOW_SIZE ) | |
! FF_ALLOCZ_TYPED_ARRAY ( s - > planar_samples , s - > channels ) )
return AVERROR ( ENOMEM ) ;
for ( ch = 0 ; ch < s - > channels ; ch + + ) {
if ( ! ( s - > planar_samples [ ch ] = av_mallocz ( ( AC3_FRAME_SIZE + AC3_BLOCK_SIZE ) *
sizeof ( * * s - > planar_samples ) ) ) )
return AVERROR ( ENOMEM ) ;
}
return 0 ;
}
/*
* Copy input samples .
* Channels are reordered from FFmpeg ' s default order to AC - 3 order .
@ -68,13 +49,14 @@ static void copy_input_samples(AC3EncodeContext *s, SampleType **samples)
/* copy and remap input samples */
for ( ch = 0 ; ch < s - > channels ; ch + + ) {
/* copy last 256 samples of previous frame to the start of the current frame */
memcpy ( & s - > planar_samples [ ch ] [ 0 ] , & s - > planar_samples [ ch ] [ AC3_BLOCK_SIZE * s - > num_blocks ] ,
AC3_BLOCK_SIZE * sizeof ( s - > planar_samples [ 0 ] [ 0 ] ) ) ;
memcpy ( & s - > planar_samples [ ch ] [ 0 ] ,
( SampleType * ) s - > planar_samples [ ch ] + AC3_BLOCK_SIZE * s - > num_blocks ,
AC3_BLOCK_SIZE * sizeof ( SampleType ) ) ;
/* copy new samples for current frame */
memcpy ( & s - > planar_samples [ ch ] [ AC3_BLOCK_SIZE ] ,
memcpy ( ( SampleType * ) s - > planar_samples [ ch ] + AC3_BLOCK_SIZE ,
samples [ s - > channel_map [ ch ] ] ,
AC3_BLOCK_SIZE * s - > num_blocks * sizeof ( s - > planar_samples [ 0 ] [ 0 ] ) ) ;
AC3_BLOCK_SIZE * s - > num_blocks * sizeof ( SampleType ) ) ;
}
}
@ -91,11 +73,11 @@ static void apply_mdct(AC3EncodeContext *s)
for ( ch = 0 ; ch < s - > channels ; ch + + ) {
for ( blk = 0 ; blk < s - > num_blocks ; blk + + ) {
AC3Block * block = & s - > blocks [ blk ] ;
const SampleType * input_samples = & s - > planar_samples [ ch ] [ blk * AC3_BLOCK_SIZE ] ;
const SampleType * input_samples = ( SampleType * ) s - > planar_samples [ ch ] + blk * AC3_BLOCK_SIZE ;
s - > fdsp - > vector_fmul ( s - > windowed_samples , input_samples ,
s - > mdct_window , AC3_BLOCK_SIZE ) ;
s - > fdsp - > vector_fmul_reverse ( s - > windowed_samples + AC3_BLOCK_SIZE ,
s - > fdsp - > vector_fmul_reverse ( ( SampleType * ) s - > windowed_samples + AC3_BLOCK_SIZE ,
& input_samples [ AC3_BLOCK_SIZE ] ,
s - > mdct_window , AC3_BLOCK_SIZE ) ;