History

swscale/yuv2rgb: add yuv42{0,2}p -> gbrp unscaled colorspace converters

Ramiro Polla committed 2 years ago

Commit 45452051 parent af5adf52 files · +60 −16Browse files

Unified · Split

2 files
  1. libswscale/yuv2rgb.c +16 −0
  2. tests/checkasm/sw_yuv2rgb.c +44 −16
libswscale/yuv2rgb.c+16−0
@@ -124,6 +124,16 @@ const int *sws_getCoefficients(int colorspace) · 123 unmodified lines
124124 dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \
125125 dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];
126126
127+#define PUTGBRP(l, i, abase) \
128+ Y = py_##l[2 * i]; \
129+ dst_##l [2 * i + 0] = g[Y]; \
130+ dst1_##l[2 * i + 0] = b[Y]; \
131+ dst2_##l[2 * i + 0] = r[Y]; \
132+ Y = py_##l[2 * i + 1]; \
133+ dst_##l [2 * i + 1] = g[Y]; \
134+ dst1_##l[2 * i + 1] = b[Y]; \
135+ dst2_##l[2 * i + 1] = r[Y];
136+
127137 #define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \
128138 static int func_name(SwsContext *c, const uint8_t *src[], \
129139 int srcStride[], int srcSliceY, int srcSliceH, \
@@ -519,6 +529,7 @@ YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) · 389 unmodified lines
519529 #endif
520530 YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1)
521531 YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1)
532+YUV420FUNC(yuv420p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
522533 YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8)
523534 YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8)
524535 YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8)
@@ -539,6 +550,7 @@ YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) · 14 unmodified lines
539550 #endif
540551 YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1)
541552 YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1)
553+YUV422FUNC(yuv422p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
542554 YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8)
543555 YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8)
544556 YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8)
@@ -604,6 +616,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) · 59 unmodified lines
604616 return yuv422p_bgr4_byte;
605617 case AV_PIX_FMT_MONOBLACK:
606618 return yuv2rgb_c_1_ordered_dither;
619+ case AV_PIX_FMT_GBRP:
620+ return yuv422p_gbrp_c;
607621 }
608622 } else {
609623 switch (c->dstFormat) {
@@ -644,6 +658,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) · 34 unmodified lines
644658 return yuv2rgb_c_4b_ordered_dither;
645659 case AV_PIX_FMT_MONOBLACK:
646660 return yuv2rgb_c_1_ordered_dither;
661+ case AV_PIX_FMT_GBRP:
662+ return yuv420p_gbrp_c;
647663 }
648664 }
649665 return NULL;
tests/checkasm/sw_yuv2rgb.c+44−16
@@ -58,6 +58,7 @@ static const int dst_fmts[] = { · 57 unmodified lines
5858 // AV_PIX_FMT_RGB4_BYTE,
5959 // AV_PIX_FMT_BGR4_BYTE,
6060 // AV_PIX_FMT_MONOBLACK,
61+ AV_PIX_FMT_GBRP,
6162 };
6263
6364 static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy)
@@ -116,13 +117,25 @@ static void check_yuv2rgb(int src_pix_fmt) · 52 unmodified lines
116117 LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]);
117118 const uint8_t *src[4] = { src_y, src_u, src_v, src_a };
118119
119− LOCAL_ALIGNED_8(uint8_t, dst0_, [2 * MAX_LINE_SIZE * 6]);
120− uint8_t *dst0[4] = { dst0_ };
121− uint8_t *lines0[2] = { dst0_, dst0_ + MAX_LINE_SIZE * 6 };
122−
123− LOCAL_ALIGNED_8(uint8_t, dst1_, [2 * MAX_LINE_SIZE * 6]);
124− uint8_t *dst1[4] = { dst1_ };
125− uint8_t *lines1[2] = { dst1_, dst1_ + MAX_LINE_SIZE * 6 };
120+ LOCAL_ALIGNED_8(uint8_t, dst0_0, [2 * MAX_LINE_SIZE * 6]);
121+ LOCAL_ALIGNED_8(uint8_t, dst0_1, [2 * MAX_LINE_SIZE]);
122+ LOCAL_ALIGNED_8(uint8_t, dst0_2, [2 * MAX_LINE_SIZE]);
123+ uint8_t *dst0[4] = { dst0_0, dst0_1, dst0_2 };
124+ uint8_t *lines0[4][2] = {
125+ { dst0_0, dst0_0 + MAX_LINE_SIZE * 6 },
126+ { dst0_1, dst0_1 + MAX_LINE_SIZE },
127+ { dst0_2, dst0_2 + MAX_LINE_SIZE }
128+ };
129+
130+ LOCAL_ALIGNED_8(uint8_t, dst1_0, [2 * MAX_LINE_SIZE * 6]);
131+ LOCAL_ALIGNED_8(uint8_t, dst1_1, [2 * MAX_LINE_SIZE]);
132+ LOCAL_ALIGNED_8(uint8_t, dst1_2, [2 * MAX_LINE_SIZE]);
133+ uint8_t *dst1[4] = { dst1_0, dst1_1, dst1_2 };
134+ uint8_t *lines1[4][2] = {
135+ { dst1_0, dst1_0 + MAX_LINE_SIZE * 6 },
136+ { dst1_1, dst1_1 + MAX_LINE_SIZE },
137+ { dst1_2, dst1_2 + MAX_LINE_SIZE }
138+ };
126139
127140 randomize_buffers(src_y, MAX_LINE_SIZE * 2);
128141 randomize_buffers(src_u, MAX_LINE_SIZE);
@@ -145,7 +158,11 @@ static void check_yuv2rgb(int src_pix_fmt) · 16 unmodified lines
145158 width >> src_desc->log2_chroma_w,
146159 width,
147160 };
148− int dstStride[4] = { MAX_LINE_SIZE * 6 };
161+ int dstStride[4] = {
162+ MAX_LINE_SIZE * 6,
163+ MAX_LINE_SIZE,
164+ MAX_LINE_SIZE,
165+ };
149166
150167 // override log level to prevent spamming of the message
151168 // "No accelerated colorspace conversion found from %s to %s"
@@ -159,8 +176,14 @@ static void check_yuv2rgb(int src_pix_fmt) · 7 unmodified lines
159176 fail();
160177
161178 if (check_func(ctx->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) {
162− memset(dst0_, 0xFF, 2 * MAX_LINE_SIZE * 6);
163− memset(dst1_, 0xFF, 2 * MAX_LINE_SIZE * 6);
179+ memset(dst0_0, 0xFF, 2 * MAX_LINE_SIZE * 6);
180+ memset(dst1_0, 0xFF, 2 * MAX_LINE_SIZE * 6);
181+ if (dst_pix_fmt == AV_PIX_FMT_GBRP) {
182+ memset(dst0_1, 0xFF, MAX_LINE_SIZE);
183+ memset(dst0_2, 0xFF, MAX_LINE_SIZE);
184+ memset(dst1_1, 0xFF, MAX_LINE_SIZE);
185+ memset(dst1_2, 0xFF, MAX_LINE_SIZE);
186+ }
164187
165188 call_ref(ctx, src, srcStride, srcSliceY,
166189 srcSliceH, dst0, dstStride);
@@ -173,19 +196,24 @@ static void check_yuv2rgb(int src_pix_fmt) · 6 unmodified lines
173196 dst_pix_fmt == AV_PIX_FMT_BGRA ||
174197 dst_pix_fmt == AV_PIX_FMT_RGB24 ||
175198 dst_pix_fmt == AV_PIX_FMT_BGR24) {
176− if (cmp_off_by_n(lines0[0], lines1[0], width * sample_size, 3) ||
177− cmp_off_by_n(lines0[1], lines1[1], width * sample_size, 3))
199+ if (cmp_off_by_n(lines0[0][0], lines1[0][0], width * sample_size, 3) ||
200+ cmp_off_by_n(lines0[0][1], lines1[0][1], width * sample_size, 3))
178201 fail();
179202 } else if (dst_pix_fmt == AV_PIX_FMT_RGB565 ||
180203 dst_pix_fmt == AV_PIX_FMT_BGR565) {
181− if (cmp_565_by_n(lines0[0], lines1[0], width, 2) ||
182− cmp_565_by_n(lines0[1], lines1[1], width, 2))
204+ if (cmp_565_by_n(lines0[0][0], lines1[0][0], width, 2) ||
205+ cmp_565_by_n(lines0[0][1], lines1[0][1], width, 2))
183206 fail();
184207 } else if (dst_pix_fmt == AV_PIX_FMT_RGB555 ||
185208 dst_pix_fmt == AV_PIX_FMT_BGR555) {
186− if (cmp_555_by_n(lines0[0], lines1[0], width, 2) ||
187− cmp_555_by_n(lines0[1], lines1[1], width, 2))
209+ if (cmp_555_by_n(lines0[0][0], lines1[0][0], width, 2) ||
210+ cmp_555_by_n(lines0[0][1], lines1[0][1], width, 2))
188211 fail();
212+ } else if (dst_pix_fmt == AV_PIX_FMT_GBRP) {
213+ for (int p = 0; p < 3; p++)
214+ for (int l = 0; l < 2; l++)
215+ if (cmp_off_by_n(lines0[p][l], lines1[p][l], width, 3))
216+ fail();
189217 } else {
190218 fail();
191219 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t