summaryrefslogtreecommitdiff
path: root/libavfilter/drawutils.h
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2022-06-02 03:48:25 -0500
committerrcombs <rcombs@rcombs.me>2022-06-19 19:18:34 -0500
commit6c3a82f0433de8ff9c35def971a736056cc8ff38 (patch)
tree5353f12b6994be4ab6e17bc500d376c673061e96 /libavfilter/drawutils.h
parenta5b3b65dc067b900be55d7edcea3cecd65a133f0 (diff)
lavfi/drawutils: improve colorspace support
- Introduce ff_draw_init2, which takes explicit colorspace and range args - Use lavu/csp and lavfi/colorspace for conversion, rather than the lavu/colorspace.h macros - Use the passed-in colorspace when performing RGB->YUV conversions The upshot of this is: - Support for YUV spaces other than BT601 - Better rounding for all conversions - Particular rounding improvements in >8-bit formats, which previously used simple left-shifts - Support for limited-range RGB - Support for full-range YUV in non-J pixfmts Due to the rounding improvements, this results in a large number of minor changes to FATE tests. Signed-off-by: rcombs <rcombs@rcombs.me>
Diffstat (limited to 'libavfilter/drawutils.h')
-rw-r--r--libavfilter/drawutils.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/libavfilter/drawutils.h b/libavfilter/drawutils.h
index 396688514e..90df55107a 100644
--- a/libavfilter/drawutils.h
+++ b/libavfilter/drawutils.h
@@ -41,8 +41,10 @@ typedef struct FFDrawContext {
uint8_t vsub[MAX_PLANES]; /*< vertical subsampling */
uint8_t hsub_max;
uint8_t vsub_max;
- int full_range;
+ enum AVColorRange range;
unsigned flags;
+ enum AVColorSpace csp;
+ double rgb2yuv[3][3];
} FFDrawContext;
typedef struct FFDrawColor {
@@ -64,13 +66,29 @@ typedef struct FFDrawColor {
*
* Only a limited number of pixel formats are supported, if format is not
* supported the function will return an error.
- * flags is combination of FF_DRAW_* flags.
- * @return 0 for success, < 0 for error
+ * @param format pixel format of the frames that will be drawn onto
+ * @param csp color space of the frames that will be drawn onto,
+ * defaulting to BT601 or RGB depending on the specified format
+ * when AVCOL_SPC_UNSPECIFIED is passed.
+ * @param range sample value range of the frames that will be drawn onto,
+ * defaulting to TV-range unless using a legacy J format
+ * when AVCOL_RANGE_UNSPECIFIED is passed.
+ * @param flags combination of FF_DRAW_* flags.
+ * @return 0 for success, < 0 for error
+ */
+int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp,
+ enum AVColorRange range, unsigned flags);
+
+/*
+ * Legacy wrapper for ff_draw_init2.
*/
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags);
+
+
/**
- * Prepare a color.
+ * Prepare a color. The rgba value passed is always 8-bit full-range in the RGB space
+ * corresponding to the space set at initialization.
*/
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4]);