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
124 dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \124 dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \
125 dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];125 dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y];
126 126
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
127#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \137#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \
128 static int func_name(SwsContext *c, const uint8_t *src[], \138 static int func_name(SwsContext *c, const uint8_t *src[], \
129 int srcStride[], int srcSliceY, int srcSliceH, \139 int srcStride[], int srcSliceY, int srcSliceH, \
@@ -519,6 +529,7 @@ YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1) · 389 unmodified lines
519#endif529#endif
520YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1)530YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1)
521YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1)531YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1)
532YUV420FUNC(yuv420p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
522YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8)533YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8)
523YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8)534YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8)
524YUV420FUNC_DITHER(yuv2rgb_c_12_ordered_dither, uint16_t, LOADDITHER12, PUTRGB12, 8)535YUV420FUNC_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
539#endif550#endif
540YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1)551YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1)
541YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1)552YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1)
553YUV422FUNC(yuv422p_gbrp_c, uint8_t, 0, 0, PUTGBRP, 8, 3)
542YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8)554YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8)
543YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8)555YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8)
544YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8)556YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8)
@@ -604,6 +616,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) · 59 unmodified lines
604 return yuv422p_bgr4_byte;616 return yuv422p_bgr4_byte;
605 case AV_PIX_FMT_MONOBLACK:617 case AV_PIX_FMT_MONOBLACK:
606 return yuv2rgb_c_1_ordered_dither;618 return yuv2rgb_c_1_ordered_dither;
619 case AV_PIX_FMT_GBRP:
620 return yuv422p_gbrp_c;
607 }621 }
608 } else {622 } else {
609 switch (c->dstFormat) {623 switch (c->dstFormat) {
@@ -644,6 +658,8 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c) · 34 unmodified lines
644 return yuv2rgb_c_4b_ordered_dither;658 return yuv2rgb_c_4b_ordered_dither;
645 case AV_PIX_FMT_MONOBLACK:659 case AV_PIX_FMT_MONOBLACK:
646 return yuv2rgb_c_1_ordered_dither;660 return yuv2rgb_c_1_ordered_dither;
661 case AV_PIX_FMT_GBRP:
662 return yuv420p_gbrp_c;
647 }663 }
648 }664 }
649 return NULL;665 return NULL;
tests/checkasm/sw_yuv2rgb.c+44−16
@@ -58,6 +58,7 @@ static const int dst_fmts[] = { · 57 unmodified lines
58// AV_PIX_FMT_RGB4_BYTE,58// AV_PIX_FMT_RGB4_BYTE,
59// AV_PIX_FMT_BGR4_BYTE,59// AV_PIX_FMT_BGR4_BYTE,
60// AV_PIX_FMT_MONOBLACK,60// AV_PIX_FMT_MONOBLACK,
61 AV_PIX_FMT_GBRP,
61};62};
62 63
63static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy)64static 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
116 LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]);117 LOCAL_ALIGNED_8(uint8_t, src_a, [MAX_LINE_SIZE * 2]);
117 const uint8_t *src[4] = { src_y, src_u, src_v, src_a };118 const uint8_t *src[4] = { src_y, src_u, src_v, src_a };
118 119
119 LOCAL_ALIGNED_8(uint8_t, dst0_, [2 * MAX_LINE_SIZE * 6]);120 LOCAL_ALIGNED_8(uint8_t, dst0_0, [2 * MAX_LINE_SIZE * 6]);
120 uint8_t *dst0[4] = { dst0_ };121 LOCAL_ALIGNED_8(uint8_t, dst0_1, [2 * MAX_LINE_SIZE]);
121 uint8_t *lines0[2] = { dst0_, dst0_ + MAX_LINE_SIZE * 6 };122 LOCAL_ALIGNED_8(uint8_t, dst0_2, [2 * MAX_LINE_SIZE]);
122 123 uint8_t *dst0[4] = { dst0_0, dst0_1, dst0_2 };
123 LOCAL_ALIGNED_8(uint8_t, dst1_, [2 * MAX_LINE_SIZE * 6]);124 uint8_t *lines0[4][2] = {
124 uint8_t *dst1[4] = { dst1_ };125 { dst0_0, dst0_0 + MAX_LINE_SIZE * 6 },
125 uint8_t *lines1[2] = { dst1_, dst1_ + 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 };
126 139
127 randomize_buffers(src_y, MAX_LINE_SIZE * 2);140 randomize_buffers(src_y, MAX_LINE_SIZE * 2);
128 randomize_buffers(src_u, MAX_LINE_SIZE);141 randomize_buffers(src_u, MAX_LINE_SIZE);
@@ -145,7 +158,11 @@ static void check_yuv2rgb(int src_pix_fmt) · 16 unmodified lines
145 width >> src_desc->log2_chroma_w,158 width >> src_desc->log2_chroma_w,
146 width,159 width,
147 };160 };
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 };
149 166
150 // override log level to prevent spamming of the message167 // override log level to prevent spamming of the message
151 // "No accelerated colorspace conversion found from %s to %s"168 // "No accelerated colorspace conversion found from %s to %s"
@@ -159,8 +176,14 @@ static void check_yuv2rgb(int src_pix_fmt) · 7 unmodified lines
159 fail();176 fail();
160 177
161 if (check_func(ctx->convert_unscaled, "%s_%s_%d", src_desc->name, dst_desc->name, width)) {178 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);179 memset(dst0_0, 0xFF, 2 * MAX_LINE_SIZE * 6);
163 memset(dst1_, 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 }
164 187
165 call_ref(ctx, src, srcStride, srcSliceY,188 call_ref(ctx, src, srcStride, srcSliceY,
166 srcSliceH, dst0, dstStride);189 srcSliceH, dst0, dstStride);
@@ -173,19 +196,24 @@ static void check_yuv2rgb(int src_pix_fmt) · 6 unmodified lines
173 dst_pix_fmt == AV_PIX_FMT_BGRA ||196 dst_pix_fmt == AV_PIX_FMT_BGRA ||
174 dst_pix_fmt == AV_PIX_FMT_RGB24 ||197 dst_pix_fmt == AV_PIX_FMT_RGB24 ||
175 dst_pix_fmt == AV_PIX_FMT_BGR24) {198 dst_pix_fmt == AV_PIX_FMT_BGR24) {
176 if (cmp_off_by_n(lines0[0], lines1[0], width * sample_size, 3) ||199 if (cmp_off_by_n(lines0[0][0], lines1[0][0], width * sample_size, 3) ||
177 cmp_off_by_n(lines0[1], lines1[1], width * sample_size, 3))200 cmp_off_by_n(lines0[0][1], lines1[0][1], width * sample_size, 3))
178 fail();201 fail();
179 } else if (dst_pix_fmt == AV_PIX_FMT_RGB565 ||202 } else if (dst_pix_fmt == AV_PIX_FMT_RGB565 ||
180 dst_pix_fmt == AV_PIX_FMT_BGR565) {203 dst_pix_fmt == AV_PIX_FMT_BGR565) {
181 if (cmp_565_by_n(lines0[0], lines1[0], width, 2) ||204 if (cmp_565_by_n(lines0[0][0], lines1[0][0], width, 2) ||
182 cmp_565_by_n(lines0[1], lines1[1], width, 2))205 cmp_565_by_n(lines0[0][1], lines1[0][1], width, 2))
183 fail();206 fail();
184 } else if (dst_pix_fmt == AV_PIX_FMT_RGB555 ||207 } else if (dst_pix_fmt == AV_PIX_FMT_RGB555 ||
185 dst_pix_fmt == AV_PIX_FMT_BGR555) {208 dst_pix_fmt == AV_PIX_FMT_BGR555) {
186 if (cmp_555_by_n(lines0[0], lines1[0], width, 2) ||209 if (cmp_555_by_n(lines0[0][0], lines1[0][0], width, 2) ||
187 cmp_555_by_n(lines0[1], lines1[1], width, 2))210 cmp_555_by_n(lines0[0][1], lines1[0][1], width, 2))
188 fail();211 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();
189 } else {217 } else {
190 fail();218 fail();
191 }219 }

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