Justin Ruggles <justin.rugg...@gmail.com> writes:

> Also use (float **) instead of (float (*)[2]). This matches the matrix
> layout in libavresample so we can reuse some assembly code between the
> two.
> ---
>  libavcodec/ac3dec.c          |   40 +++++++++++++++++++++++++++-------------
>  libavcodec/ac3dec.h          |    2 +-
>  libavcodec/ac3dsp.c          |    8 ++++----
>  libavcodec/ac3dsp.h          |    2 +-
>  libavcodec/x86/ac3dsp_init.c |   36 +++++++++++++++++++-----------------
>  5 files changed, 52 insertions(+), 36 deletions(-)
>
> diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
> index 4fc0dcf..b2a5eec 100644
> --- a/libavcodec/ac3dec.c
> +++ b/libavcodec/ac3dec.c
> @@ -300,47 +300,57 @@ static int parse_frame_header(AC3DecodeContext *s)
>   * Set stereo downmixing coefficients based on frame header info.
>   * reference: Section 7.8.2 Downmixing Into Two Channels
>   */
> -static void set_downmix_coeffs(AC3DecodeContext *s)
> +static int set_downmix_coeffs(AC3DecodeContext *s)
>  {
>      int i;
>      float cmix = gain_levels[s->  center_mix_level];
>      float smix = gain_levels[s->surround_mix_level];
>      float norm0, norm1;
>
> +    if (!s->downmix_coeffs[0]) {
> +        s->downmix_coeffs[0] = av_malloc(2 * AC3_MAX_CHANNELS *
> +                                         sizeof(**s->downmix_coeffs));
> +        if (!s->downmix_coeffs[0])
> +            return AVERROR(ENOMEM);
> +        s->downmix_coeffs[1] = s->downmix_coeffs[0] + AC3_MAX_CHANNELS;
> +    }

Instead of malloc, I'd rather keep the arrays in the context struct and
just add a couple of pointers.  Fewer ways for things to go wrong like
that.

-- 
Måns Rullgård
m...@mansr.com
_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to