[FFmpeg-devel] [PATCH] lavu/samplefmt: make av_samples_fill_arrays() return the required size of the buffer

Stefano Sabatini stefasab at gmail.com
Mon Oct 29 15:47:36 CET 2012


On date Sunday 2012-10-21 18:27:05 +0200, Michael Niedermayer encoded:
> On Sun, Oct 21, 2012 at 11:44:59AM +0200, Stefano Sabatini wrote:
> > On date Saturday 2012-09-08 01:20:48 +0200, Stefano Sabatini encoded:
> > > This is technically an API break, since documentation was stating that 0
> > > was the return error code. In practice, users will just check on ret < 0,
> > > so it *might* be a non-issue.
> > > 
> > > The value is already computed in the function, so returning it comes at
> > > no cost, and provides more information than just returning 0.
> > > ---
> > >  libavutil/samplefmt.c |    2 +-
> > >  libavutil/samplefmt.h |    3 ++-
> > >  2 files changed, 3 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c
> > > index a03648e..9da04bd 100644
> > > --- a/libavutil/samplefmt.c
> > > +++ b/libavutil/samplefmt.c
> > > @@ -171,7 +171,7 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
> > >      if (linesize)
> > >          *linesize = line_size;
> > >  
> > > -    return 0;
> > > +    return buf_size;
> > >  }
> > >  
> > >  int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
> > > diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h
> > > index 681e521..299200d 100644
> > > --- a/libavutil/samplefmt.h
> > > +++ b/libavutil/samplefmt.h
> > > @@ -179,7 +179,8 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
> > >   * @param nb_samples       the number of samples in a single channel
> > >   * @param sample_fmt       the sample format
> > >   * @param align            buffer size alignment (0 = default, 1 = no alignment)
> > > - * @return                 0 on success or a negative error code on failure
> > > + * @return                 the size in bytes required for buf, a negative error code
> > > + *                         in case of failure
> > >   */
> > >  int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
> > >                             const uint8_t *buf,
> > 
> > Ping.
> 
> should be ok

After more testing, it resulted there were some failures resulting
from the propagation of some error codes/checks. I updated the patch
accordingly. I suppose I could still split the patches into pieces, if
there is a preference for that. 
-- 
FFmpeg = Frenzy and Fundamentalist Multipurpose Philosophical Ecumenical Genius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-lavu-lavc-make-samples-buffer-creation-function-retu.patch
Type: text/x-diff
Size: 4957 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121029/e4051fdc/attachment.bin>


More information about the ffmpeg-devel mailing list