Hi,

On Thu Jan 29 2015 at 4:22:00 PM Peter Meerwald <[email protected]> wrote:
>
> diff --git a/libavcodec/g722.h b/libavcodec/g722.h
> index 71d03fc..4830170 100644
> --- a/libavcodec/g722.h
> +++ b/libavcodec/g722.h
> @@ -27,6 +27,7 @@
>
>  #include <stdint.h>
>  #include "avcodec.h"
> +#include "g722dsp.h"
>
>  #define PREV_SAMPLES_BUF_SIZE 1024
>
> @@ -61,6 +62,8 @@ typedef struct G722Context {
>          int value;
>          int prev;
>      } *paths[2];
> +
> +    G722DSPContext dsp;
>  } G722Context;
>


>  extern const int16_t ff_g722_high_inv_quant[4];
> @@ -72,6 +75,4 @@ void ff_g722_update_low_predictor(struct G722Band
> *band, const int ilow);
>  void ff_g722_update_high_predictor(struct G722Band *band, const int
> dhigh,
>                                     const int ihigh);
>
> -void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int
> *xout2);
> -
>  #endif /* AVCODEC_G722_H */
> diff --git a/libavcodec/g722dec.c b/libavcodec/g722dec.c
> index 26f288b..6e14b68 100644
> --- a/libavcodec/g722dec.c
> +++ b/libavcodec/g722dec.c
> @@ -67,6 +67,8 @@ static av_cold int g722_decode_init(AVCodecContext *
> avctx)
>      c->band[1].scale_factor = 2;
>      c->prev_samples_pos = 22;
>
> +    ff_g722dsp_init(&c->dsp);
> +
>      return 0;
>  }
>
> @@ -122,7 +124,7 @@ static int g722_decode_frame(AVCodecContext *avctx,
> void *data,
>
>          c->prev_samples[c->prev_samples_pos++] = rlow + rhigh;
>          c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
> -        ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
> +        c->dsp.apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
>                            &xout1, &xout2);
>          *out_buf++ = av_clip_int16(xout1 >> 11);
>          *out_buf++ = av_clip_int16(xout2 >> 11);
> diff --git a/libavcodec/g722dsp.c b/libavcodec/g722dsp.c
> new file mode 100644
> index 0000000..4041141
> --- /dev/null
> +++ b/libavcodec/g722dsp.c
> @@ -0,0 +1,27 @@
>

This is missing standard Libav copyright boilerplate.


> +#include "g722dsp.h"
> +#include "mathops.h"

+
> +/**
> + * quadrature mirror filter (QMF) coefficients
> + *
> + * ITU-T G.722 Table 11
> + */
>

Don't use doxygen comments in non-public headers or non-header files.

A simple /* */ should be fine.


> +static const int16_t qmf_coeffs[12] = {
> +    3, -11, 12, 32, -210, 951, 3876, -805, 362, -156, 53, -11,
> +};
> +
> +static void g722_apply_qmf(const int16_t *prev_samples, int *xout1, int
> *xout2)
> +{
> +    int i;
> +
> +    *xout1 = 0;
> +    *xout2 = 0;
> +    for (i = 0; i < 12; i++) {
> +        MAC16(*xout2, prev_samples[2*i  ], qmf_coeffs[i   ]);
> +        MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]);
> +    }
> +}
> +
> +void ff_g722dsp_init(struct G722DSPContext *c) {
> +    c->apply_qmf = g722_apply_qmf;
> +}
> diff --git a/libavcodec/g722dsp.h b/libavcodec/g722dsp.h
> new file mode 100644
> index 0000000..4da3256
> --- /dev/null
> +++ b/libavcodec/g722dsp.h
> @@ -0,0 +1,30 @@
> +/*
> + * This file is part of Libav.
> + *
> + * Libav is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * Libav is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> + */
> +
> +#ifndef AVCODEC_G722DSP_H
> +#define AVCODEC_G722DSP_H
> +
> +#include <stdint.h>
> +
> +typedef struct G722DSPContext {
> +    void (*apply_qmf)(const int16_t *prev_samples, int *xout1, int
> *xout2);
> +} G722DSPContext;
> +
> +void ff_g722dsp_init(G722DSPContext *c);
> +
> +#endif /* AVCODEC_G722DSP_H */
> diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c
> index be43794..3a3d7b7 100644
> --- a/libavcodec/g722enc.c
> +++ b/libavcodec/g722enc.c
> @@ -119,6 +119,8 @@ static av_cold int g722_encode_init(AVCodecContext *
> avctx)
>          }
>      }
>
> +    ff_g722dsp_init(&c->dsp);
> +
>      return 0;
>  error:
>      g722_encode_close(avctx);
> @@ -138,7 +140,7 @@ static inline void filter_samples(G722Context *c,
> const int16_t *samples,
>      int xout1, xout2;
>      c->prev_samples[c->prev_samples_pos++] = samples[0];
>      c->prev_samples[c->prev_samples_pos++] = samples[1];
> -    ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
> &xout1, &xout2);
> +    c->dsp.apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1,
> &xout2);
>      *xlow  = xout1 + xout2 >> 14;
>      *xhigh = xout1 - xout2 >> 14;
>      if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
>

Rest LGTM.

Timothy
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to