[FFmpeg-devel] [PATCH] Move lpc utility code from flacenc.c to lpc.{c|h}

Jai Menon realityman
Fri Aug 15 12:14:25 CEST 2008


Hi,

On Friday 15 Aug 2008 3:28:26 pm Michael Niedermayer wrote:
> On Fri, Aug 15, 2008 at 11:44:10AM +0530, Jai Menon wrote:
> > Hi,
> >
> > Attached patch moves a few functions from the flac encoder so that it can
> > be shared by the alac encoder.
> >
> > FWIW, 'make test' was successful.
> >
> > Regards,
> >
> > Jai Menon
> > <realityman at gmx.net>
> >
> > Index: libavcodec/lpc.c
> > ===================================================================
> > --- libavcodec/lpc.c	(revision 0)
> > +++ libavcodec/lpc.c	(revision 0)
> > @@ -0,0 +1,117 @@
> > +/**
> > + * LPC utility code
> > + * Copyright (c) 2006  Justin Ruggles <jruggle at earthlink.net>
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg 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.
> > + *
> > + * FFmpeg 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 FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > 02110-1301 USA + */
> > +
> > +#include <inttypes.h>
> > +#include "libavutil/avutil.h"
> > +#include "lpc.h"
> > +
> > +/**
> > + * Levinson-Durbin recursion.
> > + * Produces LPC coefficients from autocorrelation data.
> > + */
> > +void compute_lpc_coefs(const double *autoc, int max_order,
> > +                              double lpc[][MAX_LPC_ORDER], double *ref)
>
> global functions require a ff_ prefix to avoid name clashes with other libs
> when libavcodec happens to be linked to an application that also links to
> various other stuff.
>
> Also ideally there should be no fixed MAX_LPC_ORDER
>

So is is okay to allocate memory dynamically for the lpc_tmp buffer?
I was concerned about the extra overhead.

>
> [...]
>
> > Index: libavcodec/lpc.h
> > ===================================================================
> > --- libavcodec/lpc.h	(revision 0)
> > +++ libavcodec/lpc.h	(revision 0)
> > @@ -0,0 +1,45 @@
> > +/**
> > + * LPC utility code
> > + * Copyright (c) 2006  Justin Ruggles <jruggle at earthlink.net>
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg 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.
> > + *
> > + * FFmpeg 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 FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > 02110-1301 USA + */
> > +
> > +#ifndef FFMPEG_LPC_H
> > +#define FFMPEG_LPC_H
> > +
> > +#define MIN_LPC_ORDER       1
> > +#define MAX_LPC_ORDER      32
> > +
> >
> > +#define MAX_LPC_PRECISION  15
> > +#define MAX_LPC_SHIFT      15
>
> i do think they can stay where they where
>

Point noted.

Regards,

Jai Menon
<realityman at gmx.net>




More information about the ffmpeg-devel mailing list