summaryrefslogtreecommitdiff
path: root/libswscale/swscale.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2021-06-24 13:11:34 +0200
committerAnton Khirnov <anton@khirnov.net>2021-09-06 09:16:52 +0200
commit42cd64c1826d74ce523eb07c7f0910e8f0ade084 (patch)
treea08bc88dbab45f1ac1f27b393eef3f321937e37b /libswscale/swscale.h
parent3c659f861856d751fe3aa1358b1cccff3117f948 (diff)
downloadffmpeg-42cd64c1826d74ce523eb07c7f0910e8f0ade084.tar.gz
sws: add a new scaling API
Diffstat (limited to 'libswscale/swscale.h')
-rw-r--r--libswscale/swscale.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 50d6d46553..59610d0342 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"
@@ -219,6 +220,97 @@ int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
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, so they must both use
+ * refcounted buffers (if allocated by the caller, in case of 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 a non-negative number on success, a negative AVERROR code on failure.
+ */
+int sws_send_slice(struct SwsContext *c, unsigned int slice_start,
+ unsigned int slice_height);
+
+/**
+ * Request a horizontal slice of the output data to be written into the frame
+ * previously provided to sws_frame_start().
+ *
+ * @param slice_start first row of the slice; must be a multiple of
+ * sws_receive_slice_alignment()
+ * @param slice_height number of rows in the slice; must be a multiple of
+ * sws_receive_slice_alignment(), except for the last slice
+ * (i.e. when slice_start+slice_height is equal to output
+ * frame height)
+ *
+ * @return a non-negative number if the data was successfully written into the output
+ * AVERROR(EAGAIN) if more input data needs to be provided before the
+ * output can be produced
+ * another negative AVERROR code on other kinds of scaling failure
+ */
+int sws_receive_slice(struct SwsContext *c, unsigned int slice_start,
+ unsigned int slice_height);
+
+/**
+ * @return alignment required for output slices requested with sws_receive_slice().
+ * Slice offsets and sizes passed to sws_receive_slice() must be
+ * multiples of the value returned from this function.
+ */
+unsigned int sws_receive_slice_alignment(const struct SwsContext *c);
+
+/**
* @param dstRange flag indicating the while-black range of the output (1=jpeg / 0=mpeg)
* @param srcRange flag indicating the while-black range of the input (1=jpeg / 0=mpeg)
* @param table the yuv2rgb coefficients describing the output yuv space, normally ff_yuv2rgb_coeffs[x]