[FFmpeg-devel] [PATCH 4/4] Move audio channel API from libavcodec to libavcore.

Stefano Sabatini stefano.sabatini-lala
Sat Nov 20 01:36:02 CET 2010


On date Monday 2010-11-01 14:51:20 +0100, Michael Niedermayer encoded:
> On Fri, Oct 29, 2010 at 09:49:41PM -0700, Stefano Sabatini wrote:
> > ---
> >  libavcodec/audioconvert.c |   91 +++------------------------------
> >  libavcodec/audioconvert.h |   21 ++++---
> >  libavcodec/avcodec.h      |   80 +++++++++++++++-------------
> >  libavcore/Makefile        |    6 ++-
> >  libavcore/audioconvert.c  |  125 +++++++++++++++++++++++++++++++++++++++++++++
> >  libavcore/audioconvert.h  |  108 ++++++++++++++++++++++++++++++++++++++
> >  6 files changed, 299 insertions(+), 132 deletions(-)
> >  create mode 100644 libavcore/audioconvert.c
> >  create mode 100644 libavcore/audioconvert.h
> > 
> > diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
> > index 4e4063f..f3d483c 100644
> > --- a/libavcodec/audioconvert.c
> > +++ b/libavcodec/audioconvert.c
> > @@ -48,104 +48,27 @@ void avcodec_sample_fmt_string (char *buf, int buf_size, int sample_fmt)
> >  }
> >  #endif
> >  
> > -static const char* const channel_names[]={
> > -    "FL", "FR", "FC", "LFE", "BL",  "BR",  "FLC", "FRC",
> > -    "BC", "SL", "SR", "TC",  "TFL", "TFC", "TFR", "TBL",
> > -    "TBC", "TBR",
> > -    [29] = "DL",
> > -    [30] = "DR",
> > -};
> > -
> > -static const char *get_channel_name(int channel_id)
> > -{
> > -    if (channel_id<0 || channel_id>=FF_ARRAY_ELEMS(channel_names))
> > -        return NULL;
> > -    return channel_names[channel_id];
> > -}
> > -
> 
> > +#if FF_API_OLD_AUDIOCONVERT
> >  int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
> >  {
> > -    switch(nb_channels) {
> > -    case 1: return CH_LAYOUT_MONO;
> > -    case 2: return CH_LAYOUT_STEREO;
> > -    case 3: return CH_LAYOUT_SURROUND;
> > -    case 4: return CH_LAYOUT_QUAD;
> > -    case 5: return CH_LAYOUT_5POINT0;
> > -    case 6: return CH_LAYOUT_5POINT1;
> > -    case 8: return CH_LAYOUT_7POINT1;
> > -    default: return 0;
> > -    }
> > +    return av_guess_channel_layout(nb_channels);
> 
> This is not possible, codec and demuxer ids can be required for guessing

Left in libavcodec.

> [...]
> > @@ -3,12 +3,14 @@ include $(SUBDIR)../config.mak
> >  NAME = avcore
> >  FFLIBS = avutil
> >  
> > -HEADERS = avcore.h                                                      \
> > +HEADERS = audioconvert.h                                                \
> > +          avcore.h                                                      \
> 
> if you leave HEADER= \
> on its own line than future patches would a line smaller if they change the first
> entry

Fixed. 

> >            imgutils.h                                                    \
> >            parseutils.h                                                  \
> >            samplefmt.h                                                   \
> >  
> > -OBJS = imgutils.o                                                       \
> > +OBJS = audioconvert.o                                                   \
> > +       imgutils.o                                                       \
> >         parseutils.o                                                     \
> >         samplefmt.o                                                      \
> >         utils.o                                                          \
> > diff --git a/libavcore/audioconvert.c b/libavcore/audioconvert.c
> > new file mode 100644
> > index 0000000..2b6e1a8
> > --- /dev/null
> > +++ b/libavcore/audioconvert.c
> > @@ -0,0 +1,125 @@
> > +/*
> > + * Copyright (c) 2006 Michael Niedermayer <michaelni at gmx.at>
> > + *
> > + * 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
> > + */
> 
> dont forget svn cp

I'll do when I'll commit.

> and a diff against the true ancestor might be usefull
[...]
-- 
FFmpeg = Free and Fast Mysterious Portable Eretic Genius



More information about the ffmpeg-devel mailing list