[FFmpeg-devel] [PATCH 5/8] sws: add a new scaling API
Michael Niedermayer
michael at niedermayer.cc
Wed Jul 14 20:30:07 EEST 2021
On Tue, Jul 13, 2021 at 07:54:18PM +0200, Anton Khirnov wrote:
> Quoting Michael Niedermayer (2021-07-12 21:08:55)
> > On Mon, Jul 12, 2021 at 01:07:06PM +0200, Anton Khirnov wrote:
> > [...]
> > > diff --git a/libswscale/swscale.h b/libswscale/swscale.h
> > > index 50d6d46553..41eacd2dea 100644
> > > --- a/libswscale/swscale.h
> > > +++ b/libswscale/swscale.h
> > > @@ -30,6 +30,7 @@
> > > #include <stdint.h>
> > >
> > > #include "libavutil/avutil.h"
> > > +#include "libavutil/frame.h"
> > > #include "libavutil/log.h"
> > > #include "libavutil/pixfmt.h"
> > > #include "version.h"
> > > @@ -218,6 +219,85 @@ int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
> > > const int srcStride[], int srcSliceY, int srcSliceH,
> > > uint8_t *const dst[], const int dstStride[]);
> > >
> > > +/**
> > > + * Scale source data from src and write the output to dst.
> > > + *
> > > + * This is merely a convenience wrapper around
> > > + * - sws_frame_start()
> > > + * - sws_send_slice(0, src->height)
> > > + * - sws_receive_slice(0, dst->height)
> > > + * - sws_frame_end()
> > > + *
> > > + * @param dst The destination frame. See documentation for sws_frame_start() for
> > > + * more details.
> > > + * @param src The source frame.
> > > + *
> > > + * @return 0 on success, a negative AVERROR code on failure
> > > + */
> > > +int sws_scale_frame(struct SwsContext *c, AVFrame *dst, const AVFrame *src);
> > > +
> > > +/**
> > > + * Initialize the scaling process for a given pair of source/destination frames.
> > > + * Must be called before any calls to sws_send_slice() and sws_receive_slice().
> > > + *
> > > + * This function will retain references to src and dst.
> > > + *
> > > + * @param dst The destination frame.
> > > + *
> > > + * The data buffers may either be already allocated by the caller or
> > > + * left clear, in which case they will be allocated by the scaler.
> > > + * The latter may have performance advantages - e.g. in certain cases
> > > + * some output planes may be references to input planes, rather than
> > > + * copies.
> > > + *
> > > + * Output data will be written into this frame in successful
> > > + * sws_receive_slice() calls.
> > > + * @param src The source frame. The data buffers must be allocated, but the
> > > + * frame data does not have to be ready at this point. Data
> > > + * availability is then signalled by sws_send_slice().
> > > + * @return 0 on success, a negative AVERROR code on failure
> > > + *
> > > + * @see sws_frame_end()
> > > + */
> > > +int sws_frame_start(struct SwsContext *c, AVFrame *dst, const AVFrame *src);
> > > +
> > > +/**
> > > + * Finish the scaling process for a pair of source/destination frames previously
> > > + * submitted with sws_frame_start(). Must be called after all sws_send_slice()
> > > + * and sws_receive_slice() calls are done, before any new sws_frame_start()
> > > + * calls.
> > > + */
> > > +void sws_frame_end(struct SwsContext *c);
> > > +
> >
> > > +/**
> > > + * Indicate that a horizontal slice of input data is available in the source
> > > + * frame previously provided to sws_frame_start(). The slices may be provided in
> > > + * any order, but may not overlap. For vertically subsampled pixel formats, the
> > > + * slices must be aligned according to subsampling.
> > > + *
> > > + * @param slice_start first row of the slice
> > > + * @param slice_height number of rows in the slice
> > > + *
> > > + * @return 0 on success, a negative AVERROR code on failure.
> > > + */
> > > +int sws_send_slice(struct SwsContext *c, unsigned int slice_start,
> > > + unsigned int slice_height);
> >
> > I suggest to use non 0 on success.
>
> Outright >0, or >= 0?
i meant >= 0 / non negative
>
> > That could then be extended in the future for example to provide information
> > about how many lines have already been consumed and its memory be reused
>
> I will amend the patch.
>
> Are you satisfied with the API otherwise?
yes the API in this patch looks nice. I havnt looked over all other code yet
Thanks
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The day soldiers stop bringing you their problems is the day you have stopped
leading them. They have either lost confidence that you can help or concluded
you do not care. Either case is a failure of leadership. - Colin Powell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20210714/4d561f21/attachment.sig>
More information about the ffmpeg-devel
mailing list