[FFmpeg-devel] [PATCH] Add af_resample - sample fmt and channel layout conversion filter
Michael Niedermayer
michaelni
Mon Sep 27 02:21:49 CEST 2010
On Mon, Sep 27, 2010 at 12:40:31AM +0200, Stefano Sabatini wrote:
> On date Wednesday 2010-09-22 23:21:37 +0200, Michael Niedermayer encoded:
> > On Sun, Sep 12, 2010 at 02:50:00PM -0700, S.N. Hemanth Meenakshisundaram wrote:
> > >
> > > Now modified af_resample to wrap the channel mix functions in
> > > lavc/resample.c the way Stefano wanted - exposing the channel mix
> > > routines as ff_* functions.
> > >
> > > With this af_resample has no duplicate code, calls lavc routines for
> > > both sample format conversion and channel mixing.
> > >
> > > This patch contains the extra resample_internal.h header and
> > > audioconvert functions required to represent the channel conversion
> > > required as a number.
> > >
> > > The patch isn't well split now, but once any changes required to this
> > > are done, I will split it properly. Please review and comment.
> > >
> > > af_resample is required for ffmpeg.c integration and many other lavfi
> > > audio filters to work.
> > >
> > > Regards,
> > >
> > > ---
> > > libavcodec/audioconvert.c | 17 ++
> > > libavcodec/audioconvert.h | 10 +
> > > libavcodec/resample.c | 21 ++-
> > > libavcodec/resample_internal.h | 36 ++++
> > > libavfilter/Makefile | 1 +
> > > libavfilter/af_resample.c | 378 ++++++++++++++++++++++++++++++++++++++++
> > > libavfilter/allfilters.c | 1 +
> > > 7 files changed, 454 insertions(+), 10 deletions(-)
> > > create mode 100644 libavcodec/resample_internal.h
> > > create mode 100644 libavfilter/af_resample.c
> > >
> > >
> > >
> >
> > > libavcodec/audioconvert.c | 17 +
> > > libavcodec/audioconvert.h | 10 +
> > > libavcodec/resample.c | 21 +-
> > > libavcodec/resample_internal.h | 36 +++
> > > libavfilter/Makefile | 1
> > > libavfilter/af_resample.c | 378 +++++++++++++++++++++++++++++++++++++++++
> > > libavfilter/allfilters.c | 1
> > > 7 files changed, 454 insertions(+), 10 deletions(-)
> > > 331672e66f98cef708612cf26bbc18562a188c7f 0001-Add-af_resample-sample-fmt-and-channel-layout-conver.patch
> > > diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
> > > index c6dc1b1..17fa19a 100644
> > > --- a/libavcodec/audioconvert.c
> > > +++ b/libavcodec/audioconvert.c
> > > @@ -121,6 +121,11 @@ static const struct {
> > > { 0 }
> > > };
> > >
> > > +int avcodec_get_num_channel_layouts(void)
> > > +{
> > > + return (sizeof(channel_layout_map)/sizeof(channel_layout_map[0]));
> > > +}
> >
> > the number is something close to 2^channels
> >
> >
> > > +
> > > int64_t avcodec_get_channel_layout(const char *name)
> > > {
> > > int i = 0;
> > > @@ -162,6 +167,18 @@ void avcodec_get_channel_layout_string(char *buf, int buf_size, int nb_channels,
> > > }
> > > }
> > >
> > > +int avcodec_get_channel_layout_index(int64_t channel_layout)
> > > +{
> > > + int i = 1;
> > > + do {
> > > + if (channel_layout_map[i].layout == channel_layout)
> > > + return i;
> > > + i++;
> > > + } while (channel_layout_map[i].name);
> > > +
> > > + return 0;
> > > +}
> >
> > there are more layouts besides neither of these functions belong to public api
> >
> >
> > [...]
> > > @@ -53,7 +54,7 @@ struct ReSampleContext {
> > > };
> > >
> > > /* n1: number of samples */
> > > -static void stereo_to_mono(short *output, short *input, int n1)
> > > +void ff_stereo_to_mono(short *output, short *input, int n1)
> > > {
> > > short *p, *q;
> > > int n = n1;
> >
> > the functions belong to libavfilter
> > what is the plan to move them there?
>
> Impossible as lavc uses that functions internally. The plan was to
resample uses them, resample doesnt belong to lavc, not more than
sws would belong there
> directly use them, and move to something better when we'll have a
> revisited resampling/conversion API, a libavresample was mentioned.
> Since this is not going to take small time, the idea was to use the
> quickest solution and not stall audio lavfi development.
the quickest is to copy the 2 pages of poor code not to export it as
public ABI/API from the wrong lib
that API/ABI requires maintaince and is not a small burden when things
have to be moved to the correct place or when API/ABI changes which with
such trashy code will happen unless development stops
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100927/ce36dc1b/attachment.pgp>
More information about the ffmpeg-devel
mailing list