Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Ramiro Polla <ramiro.polla@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v2 2/5] swscale/yuv2rgb: prepare YUV2RGBFUNC macro for multi-planar rgb
Date: Tue,  6 Aug 2024 12:51:03 +0200
Message-ID: <20240806105106.59866-3-ramiro.polla@gmail.com> (raw)
In-Reply-To: <20240806105106.59866-1-ramiro.polla@gmail.com>

This will be used in the upcoming yuv42{0,2}p -> gbrp unscaled
colorspace converters.

There is no difference in performance.
---
 libswscale/yuv2rgb.c | 83 +++++++++++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 35 deletions(-)

diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index d77660b3a3..31d10235ef 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -124,7 +124,7 @@ const int *sws_getCoefficients(int colorspace)
     dst_##l[12 * i +  8] = dst_##l[12 * i +  9] = g[Y]; \
     dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];
 
-#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422)                     \
+#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes)      \
     static int func_name(SwsContext *c, const uint8_t *src[],               \
                          int srcStride[], int srcSliceY, int srcSliceH,     \
                          uint8_t *dst[], int dstStride[])                   \
@@ -137,6 +137,7 @@ const int *sws_getCoefficients(int colorspace)
                 (dst_type *)(dst[0] + (yd)     * dstStride[0]);             \
             dst_type *dst_2 =                                               \
                 (dst_type *)(dst[0] + (yd + 1) * dstStride[0]);             \
+            dst_type av_unused *dst1_1, *dst1_2, *dst2_1, *dst2_2;          \
             dst_type av_unused *r, *g, *b;                                  \
             const uint8_t *py_1 = src[0] +  y       * srcStride[0];         \
             const uint8_t *py_2 = py_1   +            srcStride[0];         \
@@ -145,6 +146,12 @@ const int *sws_getCoefficients(int colorspace)
             const uint8_t av_unused *pu_2, *pv_2;                           \
             const uint8_t av_unused *pa_1, *pa_2;                           \
             unsigned int h_size = c->dstW >> 3;                             \
+            if (nb_dst_planes > 1) {                                        \
+                dst1_1 = (dst_type *)(dst[1] + (yd)     * dstStride[1]);    \
+                dst1_2 = (dst_type *)(dst[1] + (yd + 1) * dstStride[1]);    \
+                dst2_1 = (dst_type *)(dst[2] + (yd)     * dstStride[2]);    \
+                dst2_2 = (dst_type *)(dst[2] + (yd + 1) * dstStride[2]);    \
+            }                                                               \
             if (yuv422) {                                                   \
                 pu_2 = pu_1 + srcStride[1];                                 \
                 pv_2 = pv_1 + srcStride[2];                                 \
@@ -156,7 +163,7 @@ const int *sws_getCoefficients(int colorspace)
             while (h_size--) {                                              \
                 int av_unused U, V, Y;                                      \
 
-#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \
+#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes) \
     pu_1  += 4 >> ss;                               \
     pv_1  += 4 >> ss;                               \
     if (yuv422) {                                   \
@@ -171,6 +178,12 @@ const int *sws_getCoefficients(int colorspace)
     }                                               \
     dst_1 += dst_delta >> ss;                       \
     dst_2 += dst_delta >> ss;                       \
+    if (nb_dst_planes > 1) {                        \
+        dst1_1 += dst_delta >> ss;                  \
+        dst1_2 += dst_delta >> ss;                  \
+        dst2_1 += dst_delta >> ss;                  \
+        dst2_2 += dst_delta >> ss;                  \
+    }                                               \
     }                                               \
     if (c->dstW & (4 >> ss)) {                      \
         int av_unused Y, U, V;                      \
@@ -181,8 +194,8 @@ const int *sws_getCoefficients(int colorspace)
         return srcSliceH;                           \
     }
 
-#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \
-    YUV2RGBFUNC(func_name, dst_type, alpha, 0)                          \
+#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \
+    YUV2RGBFUNC(func_name, dst_type, alpha, 0, nb_dst_planes)           \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
         PUTFUNC(2, 0, abase);                                           \
@@ -198,7 +211,7 @@ const int *sws_getCoefficients(int colorspace)
         LOADCHROMA(1, 3);                                               \
         PUTFUNC(2, 3, abase);                                           \
         PUTFUNC(1, 3, abase);                                           \
-    ENDYUV2RGBLINE(dst_delta, 0, alpha, 0)                              \
+    ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes)               \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
         PUTFUNC(2, 0, abase);                                           \
@@ -206,14 +219,14 @@ const int *sws_getCoefficients(int colorspace)
         LOADCHROMA(1, 1);                                               \
         PUTFUNC(2, 1, abase);                                           \
         PUTFUNC(1, 1, abase);                                           \
-    ENDYUV2RGBLINE(dst_delta, 1, alpha, 0)                              \
+    ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes)               \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
         PUTFUNC(2, 0, abase);                                           \
     ENDYUV2RGBFUNC()
 
-#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \
-    YUV2RGBFUNC(func_name, dst_type, alpha, 1)                          \
+#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \
+    YUV2RGBFUNC(func_name, dst_type, alpha, 1, nb_dst_planes)           \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
                                                                         \
@@ -237,7 +250,7 @@ const int *sws_getCoefficients(int colorspace)
                                                                         \
         LOADCHROMA(1, 3);                                               \
         PUTFUNC(1, 3, abase);                                           \
-    ENDYUV2RGBLINE(dst_delta, 0, alpha, 1)                              \
+    ENDYUV2RGBLINE(dst_delta, 0, alpha, 1, nb_dst_planes)               \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
                                                                         \
@@ -249,7 +262,7 @@ const int *sws_getCoefficients(int colorspace)
                                                                         \
         LOADCHROMA(1, 1);                                               \
         PUTFUNC(1, 1, abase);                                           \
-    ENDYUV2RGBLINE(dst_delta, 1, alpha, 1)                              \
+    ENDYUV2RGBLINE(dst_delta, 1, alpha, 1, nb_dst_planes)               \
         LOADCHROMA(1, 0);                                               \
         PUTFUNC(1, 0, abase);                                           \
                                                                         \
@@ -258,7 +271,7 @@ const int *sws_getCoefficients(int colorspace)
     ENDYUV2RGBFUNC()
 
 #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \
-    YUV2RGBFUNC(func_name, dst_type, 0, 0)                              \
+    YUV2RGBFUNC(func_name, dst_type, 0, 0, 1)                           \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -276,7 +289,7 @@ const int *sws_getCoefficients(int colorspace)
         LOADCHROMA(1, 3);                                               \
         PUTFUNC(2, 3, 6 + 8);                                           \
         PUTFUNC(1, 3, 6);                                               \
-    ENDYUV2RGBLINE(dst_delta, 0, 0, 0)                                  \
+    ENDYUV2RGBLINE(dst_delta, 0, 0, 0, 1)                               \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -286,7 +299,7 @@ const int *sws_getCoefficients(int colorspace)
         LOADCHROMA(1, 1);                                               \
         PUTFUNC(2, 1, 2 + 8);                                           \
         PUTFUNC(1, 1, 2);                                               \
-    ENDYUV2RGBLINE(dst_delta, 1, 0, 0)                                  \
+    ENDYUV2RGBLINE(dst_delta, 1, 0, 0, 1)                               \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -295,7 +308,7 @@ const int *sws_getCoefficients(int colorspace)
     ENDYUV2RGBFUNC()
 
 #define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \
-    YUV2RGBFUNC(func_name, dst_type, 0, 1)                              \
+    YUV2RGBFUNC(func_name, dst_type, 0, 1, 1)                           \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -321,7 +334,7 @@ const int *sws_getCoefficients(int colorspace)
                                                                         \
         LOADCHROMA(1, 3);                                               \
         PUTFUNC(1, 3, 6);                                               \
-    ENDYUV2RGBLINE(dst_delta, 0, 0, 1)                                  \
+    ENDYUV2RGBLINE(dst_delta, 0, 0, 1, 1)                               \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -335,7 +348,7 @@ const int *sws_getCoefficients(int colorspace)
                                                                         \
         LOADCHROMA(1, 1);                                               \
         PUTFUNC(1, 1, 2);                                               \
-    ENDYUV2RGBLINE(dst_delta, 1, 0, 1)                                  \
+    ENDYUV2RGBLINE(dst_delta, 1, 0, 1, 1)                               \
         LOADDITHER                                                      \
                                                                         \
         LOADCHROMA(1, 0);                                               \
@@ -431,7 +444,7 @@ const int *sws_getCoefficients(int colorspace)
                          g[Y +  d64[1 + o]] +       \
                          b[Y + d128[1 + o]];
 
-YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0)
+YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0, 1)
     const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
     char out_1 = 0, out_2 = 0;
     g = c->table_gU[128 + YUVRGB_TABLE_HEADROOM] + c->table_gV[128 + YUVRGB_TABLE_HEADROOM];
@@ -494,18 +507,18 @@ YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0)
 ENDYUV2RGBFUNC()
 
 // YUV420
-YUV420FUNC(yuv2rgb_c_48,     uint8_t,  0,  0, PUTRGB48, 48)
-YUV420FUNC(yuv2rgb_c_bgr48,  uint8_t,  0,  0, PUTBGR48, 48)
-YUV420FUNC(yuv2rgb_c_32,     uint32_t, 0,  0, PUTRGB,    8)
+YUV420FUNC(yuv2rgb_c_48,     uint8_t,  0,  0, PUTRGB48, 48, 1)
+YUV420FUNC(yuv2rgb_c_bgr48,  uint8_t,  0,  0, PUTBGR48, 48, 1)
+YUV420FUNC(yuv2rgb_c_32,     uint32_t, 0,  0, PUTRGB,    8, 1)
 #if HAVE_BIGENDIAN
-YUV420FUNC(yuva2argb_c,      uint32_t, 1, 24, PUTRGBA,   8)
-YUV420FUNC(yuva2rgba_c,      uint32_t, 1,  0, PUTRGBA,   8)
+YUV420FUNC(yuva2argb_c,      uint32_t, 1, 24, PUTRGBA,   8, 1)
+YUV420FUNC(yuva2rgba_c,      uint32_t, 1,  0, PUTRGBA,   8, 1)
 #else
-YUV420FUNC(yuva2rgba_c,      uint32_t, 1, 24, PUTRGBA,   8)
-YUV420FUNC(yuva2argb_c,      uint32_t, 1,  0, PUTRGBA,   8)
+YUV420FUNC(yuva2rgba_c,      uint32_t, 1, 24, PUTRGBA,   8, 1)
+YUV420FUNC(yuva2argb_c,      uint32_t, 1,  0, PUTRGBA,   8, 1)
 #endif
-YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t,  0,  0, PUTRGB24, 24)
-YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t,  0,  0, PUTBGR24, 24)
+YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t,  0,  0, PUTRGB24, 24, 1)
+YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t,  0,  0, PUTBGR24, 24, 1)
 YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16,  PUTRGB16,  8)
 YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15,  PUTRGB15,  8)
 YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12,  PUTRGB12,  8)
@@ -514,18 +527,18 @@ YUV420FUNC_DITHER(yuv2rgb_c_4_ordered_dither,  uint8_t,  LOADDITHER4D,  PUTRGB4D
 YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t,  LOADDITHER4DB, PUTRGB4DB, 8)
 
 // YUV422
-YUV422FUNC(yuv422p_rgb48_c,  uint8_t,  0,  0, PUTRGB48, 48)
-YUV422FUNC(yuv422p_bgr48_c,  uint8_t,  0,  0, PUTBGR48, 48)
-YUV422FUNC(yuv422p_rgb32_c,  uint32_t, 0,  0, PUTRGB,    8)
+YUV422FUNC(yuv422p_rgb48_c,  uint8_t,  0,  0, PUTRGB48, 48, 1)
+YUV422FUNC(yuv422p_bgr48_c,  uint8_t,  0,  0, PUTBGR48, 48, 1)
+YUV422FUNC(yuv422p_rgb32_c,  uint32_t, 0,  0, PUTRGB,    8, 1)
 #if HAVE_BIGENDIAN
-YUV422FUNC(yuva422p_argb_c,  uint32_t, 1, 24, PUTRGBA,   8)
-YUV422FUNC(yuva422p_rgba_c,  uint32_t, 1,  0, PUTRGBA,   8)
+YUV422FUNC(yuva422p_argb_c,  uint32_t, 1, 24, PUTRGBA,   8, 1)
+YUV422FUNC(yuva422p_rgba_c,  uint32_t, 1,  0, PUTRGBA,   8, 1)
 #else
-YUV422FUNC(yuva422p_rgba_c,  uint32_t, 1, 24, PUTRGBA,   8)
-YUV422FUNC(yuva422p_argb_c,  uint32_t, 1,  0, PUTRGBA,   8)
+YUV422FUNC(yuva422p_rgba_c,  uint32_t, 1, 24, PUTRGBA,   8, 1)
+YUV422FUNC(yuva422p_argb_c,  uint32_t, 1,  0, PUTRGBA,   8, 1)
 #endif
-YUV422FUNC(yuv422p_rgb24_c,  uint8_t,  0,  0, PUTRGB24, 24)
-YUV422FUNC(yuv422p_bgr24_c,  uint8_t,  0,  0, PUTBGR24, 24)
+YUV422FUNC(yuv422p_rgb24_c,  uint8_t,  0,  0, PUTRGB24, 24, 1)
+YUV422FUNC(yuv422p_bgr24_c,  uint8_t,  0,  0, PUTBGR24, 24, 1)
 YUV422FUNC_DITHER(yuv422p_bgr16,     uint16_t, LOADDITHER16,  PUTRGB16,  8)
 YUV422FUNC_DITHER(yuv422p_bgr15,     uint16_t, LOADDITHER15,  PUTRGB15,  8)
 YUV422FUNC_DITHER(yuv422p_bgr12,     uint16_t, LOADDITHER12,  PUTRGB12,  8)
-- 
2.30.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2024-08-06 10:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 10:51 [FFmpeg-devel] [PATCH v2 0/5] swscale/yuv2rgb: add yuv42{0, 2}p -> gbrp unscaled colorspace converters Ramiro Polla
2024-08-06 10:51 ` [FFmpeg-devel] [PATCH v2 1/5] swscale/yuv2rgb: prepare LOADCHROMA/PUTFUNC macros for multi-planar rgb Ramiro Polla
2024-08-06 10:51 ` Ramiro Polla [this message]
2024-08-06 10:51 ` [FFmpeg-devel] [PATCH v2 3/5] swscale/yuv2rgb: add yuv42{0, 2}p -> gbrp unscaled colorspace converters Ramiro Polla
2024-08-06 10:51 ` [FFmpeg-devel] [PATCH v2 4/5] swscale/x86/yuv2rgb: add ssse3 " Ramiro Polla
2024-08-06 10:51 ` [FFmpeg-devel] [PATCH v2 5/5] swscale/aarch64/yuv2rgb: add neon " Ramiro Polla
2024-08-14 12:23   ` Martin Storsjö
2024-08-15 14:32 ` [FFmpeg-devel] [PATCH v2 0/5] swscale/yuv2rgb: add " Ramiro Polla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240806105106.59866-3-ramiro.polla@gmail.com \
    --to=ramiro.polla@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git