[FFmpeg-devel] [PATCH 1/6] ac3enc_fixed: convert to 32-bit sample format

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Sat Jan 9 23:01:51 EET 2021


Lynne:
> @@ -165,7 +164,11 @@ typedef struct AC3EncodeContext {
>      AVCodecContext *avctx;                  ///< parent AVCodecContext
>      PutBitContext pb;                       ///< bitstream writer context
>      AudioDSPContext adsp;
> +#if AC3ENC_FLOAT
>      AVFloatDSPContext *fdsp;
> +#else
> +    AVFixedDSPContext *fdsp;
> +#endif
>      MECmpContext mecc;
>      AC3DSPContext ac3dsp;                   ///< AC-3 optimized functions
>      FFTContext mdct;                        ///< FFT context for MDCT calculation
[...]
> @@ -118,9 +89,10 @@ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
>  static av_cold void ac3_fixed_mdct_end(AC3EncodeContext *s)
>  {
>      ff_mdct_end(&s->mdct);
> +    av_freep(&s->fdsp);
> +    av_freep(&s->mdct_window);
>  }

ff_ac3_encode_close already unconditionally frees fdsp, so freeing it
above is either unnecessary or ac3_float_mdct_end should also free its
fdsp (and ff_ac3_encode_close shouldn't). Freeing mdct_window can also
be moved to ff_ac3_encode_close (which already frees several buffers
whose pointed-to-type depends upon the encoding mode).
Notice that ac3enc.c uses the fixed-point mode, but the layout of
AC3EncodeContext does not depend upon this (apart from pointed-to-types,
of course). Actually, ff_mdct_end does the same for both fixed- and
floating-point mode, so one could even incorporate
ac3_fixed/float_mdct_end into ff_ac3_encode_close.

- Andreas


More information about the ffmpeg-devel mailing list