[FFmpeg-devel] [PATCH 3/4] Separate window function from autocorrelation.

Måns Rullgård mans
Thu Jan 20 03:51:18 CET 2011


Justin Ruggles <justin.ruggles at gmail.com> writes:

> ---
>  libavcodec/alacenc.c         |    8 +++++-
>  libavcodec/flacenc.c         |    7 +++-
>  libavcodec/lpc.c             |   60 ++++++++++++++++++++++++++++--------------
>  libavcodec/lpc.h             |   25 +++++++++++++++--
>  libavcodec/ra144enc.c        |   14 +++++++++-
>  libavcodec/x86/dsputil_mmx.h |    3 --
>  libavcodec/x86/lpc_mmx.c     |   21 +++++----------
>  7 files changed, 94 insertions(+), 44 deletions(-)
>
>
> diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
> index cd31c15..854286e 100644
> --- a/libavcodec/alacenc.c
> +++ b/libavcodec/alacenc.c
> @@ -375,6 +375,7 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
>  {
>      AlacEncodeContext *s    = avctx->priv_data;
>      uint8_t *alac_extradata = av_mallocz(ALAC_EXTRADATA_SIZE+1);
> +    int ret;
>  
>      avctx->frame_size      = DEFAULT_FRAME_SIZE;
>      avctx->bits_per_coded_sample = DEFAULT_SAMPLE_SIZE;
> @@ -451,10 +452,12 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
>      avctx->coded_frame->key_frame = 1;
>  
>      s->avctx = avctx;
> -    ff_lpc_init(&s->lpc_ctx, s->avctx->frame_size, s->min_prediction_order,
> +    ret = ff_lpc_init(&s->lpc_ctx, s->avctx->frame_size, s->min_prediction_order,
>                  s->max_prediction_order, ALAC_MAX_LPC_PRECISION,
>                  AV_LPC_TYPE_LEVINSON, 0, ORDER_METHOD_EST, ALAC_MAX_LPC_SHIFT,
>                  1);
> +    if (ret)
> +        return ret;
>  
>      return 0;

Simply "return ret" will do just fine, here and elsewhere.

> @@ -51,28 +51,26 @@ static void apply_welch_window(const int32_t *data, int len, double *w_data)
>      }
>  }
>  
> +void ff_lpc_apply_welch_window(LPCContext *c, const int32_t *data, int len,
> +                               double *w_data)
> +{
> +    c->lpc_apply_welch_window(data, len, w_data);
> +}

Again, why wrapper?  Use the function pointer directly wherever this
is called.

> diff --git a/libavcodec/lpc.h b/libavcodec/lpc.h
> index 7573bf1..5572c26 100644
> --- a/libavcodec/lpc.h
> +++ b/libavcodec/lpc.h
> @@ -46,8 +46,10 @@ typedef struct LPCContext {
>      int omethod;
>      int max_shift;
>      int zero_shift;
> +    double *windowed_samples;
>  
> -    void (*lpc_compute_autocorr)(const int32_t *data, int len, int lag,
> +    void (*lpc_apply_welch_window)(const int32_t *data, int len, double *w_data);
> +    void (*lpc_compute_autocorr)(const double *data, int len, int lag,
>                                   double *autoc);
>  } LPCContext;
>  
> @@ -66,6 +68,18 @@ int ff_lpc_calc_coefs(LPCContext *s, const int32_t *samples, int blocksize,
>                        int32_t coefs[][MAX_LPC_ORDER], int *shift);
>  
>  /**
> + * Apply a Welch window to an array of input samples.
> + * The output samples have the same scale as the input, but are in double
> + * sample format.
> + * @param c       LPC context
> + * @param data    input samples
> + * @param len     number of input samples
> + * @param w_data  output samples
> + */
> +void ff_lpc_apply_welch_window(LPCContext *c, const int32_t *data, int len,
> +                               double *w_data);

Get rid of the wrapper and move the doxy comment to the struct.

Rest OK.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list