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

Michael Niedermayer michaelni at gmx.at
Sun Oct 21 18:27:05 CEST 2012


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

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121021/ba9189ca/attachment.asc>


More information about the ffmpeg-devel mailing list