[FFmpeg-devel] [PATCH] Move audioconvert API from libavcodec to libavcore.

Michael Niedermayer michaelni
Fri Jan 7 16:20:06 CET 2011


On Sat, Nov 20, 2010 at 07:32:07PM +0100, Stefano Sabatini wrote:
> On date Saturday 2010-11-20 19:17:11 +0100, Stefano Sabatini encoded:
> > ---
> >  libavcodec/audioconvert.c |   74 ++++-----------------------------------
> >  libavcodec/audioconvert.h |    8 ++++
> >  libavcore/audioconvert.c  |   85 +++++++++++++++++++++++++++++++++++++++++++++
> >  libavcore/audioconvert.h  |   39 ++++++++++++++++++++
> >  4 files changed, 140 insertions(+), 66 deletions(-)
> 
> Updated with a fix.
> 
> I wonder if we should make AVAudioConvertContext an AVClass context
> (this would be useful e.g. for logging).
> -- 
> FFmpeg = Forgiving Fascinating Magnificient Powered Earthshaking Gorilla

>  libavcodec/audioconvert.c |   74 ++++------------------------------------
>  libavcodec/audioconvert.h |    8 ++++
>  libavcore/audioconvert.c  |   85 ++++++++++++++++++++++++++++++++++++++++++++++
>  libavcore/audioconvert.h  |   39 +++++++++++++++++++++
>  4 files changed, 140 insertions(+), 66 deletions(-)
> 9104c911dacd1a8d46d53c4bff5632aa2f87a48e  0002-Move-audioconvert-API-from-libavcodec-to-libavcore.patch
> From fbb9912029863a93c27a0cc789d4aa5e6c54bf76 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Sat, 20 Nov 2010 19:07:38 +0100
> Subject: [PATCH] Move audioconvert API from libavcodec to libavcore.
> 
> ---
>  libavcodec/audioconvert.c |   74 ++++-----------------------------------
>  libavcodec/audioconvert.h |    8 ++++
>  libavcore/audioconvert.c  |   85 +++++++++++++++++++++++++++++++++++++++++++++
>  libavcore/audioconvert.h  |   39 ++++++++++++++++++++
>  4 files changed, 140 insertions(+), 66 deletions(-)
> 
> diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
> index 609fd1c..5e8b19e 100644
> --- a/libavcodec/audioconvert.c
> +++ b/libavcodec/audioconvert.c
> @@ -27,7 +27,7 @@
>  
>  #include "libavutil/avstring.h"
>  #include "libavutil/libm.h"
> -#include "libavcore/samplefmt.h"
> +#include "libavcore/audioconvert.h"
>  #include "avcodec.h"
>  #include "audioconvert.h"
>  
> @@ -77,87 +77,29 @@ int avcodec_channel_layout_num_channels(int64_t channel_layout)
>  {
>      return av_get_channel_layout_nb_channels(channel_layout);
>  }
> -#endif
>  
> -struct AVAudioConvert {
> -    int in_channels, out_channels;
> -    int fmt_pair;
> -};
> +typedef AVAudioConvert AudioConvertContext;
>  
>  AVAudioConvert *av_audio_convert_alloc(enum AVSampleFormat out_fmt, int out_channels,
>                                         enum AVSampleFormat in_fmt, int in_channels,
>                                         const float *matrix, int flags)
>  {
> -    AVAudioConvert *ctx;
> -    if (in_channels!=out_channels)
> -        return NULL;  /* FIXME: not supported */
> -    ctx = av_malloc(sizeof(AVAudioConvert));
> -    if (!ctx)
> +    AVAudioConvert *ctx = NULL;
> +    if (av_audio_convert_alloc2(&ctx, out_fmt, out_channels, in_fmt, in_channels, matrix, flags) < 0)
>          return NULL;

as you change the API, i would suggest you pass parent context and log offset
so error messages can be logged correctly

except that the patch should be ok if tested

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Democracy is the form of government in which you can choose your dictator
-------------- 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/20110107/b1c6dff7/attachment.pgp>



More information about the ffmpeg-devel mailing list