History

swscale/yuv2rgb: prepare YUV2RGBFUNC macro for multi-planar rgb

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

Ramiro Polla committed 2 years ago

Commit af5adf51 parent 24063e71 file · +48 −35Browse files

Unified · Split

libswscale/yuv2rgb.c+48−35
@@ -124,7 +124,7 @@ 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 YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \
127+#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \
128128 static int func_name(SwsContext *c, const uint8_t *src[], \
129129 int srcStride[], int srcSliceY, int srcSliceH, \
130130 uint8_t *dst[], int dstStride[]) \
@@ -137,6 +137,7 @@ const int *sws_getCoefficients(int colorspace) · 6 unmodified lines
137137 (dst_type *)(dst[0] + (yd) * dstStride[0]); \
138138 dst_type *dst_2 = \
139139 (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \
140+ dst_type av_unused *dst1_1, *dst1_2, *dst2_1, *dst2_2; \
140141 dst_type av_unused *r, *g, *b; \
141142 const uint8_t *py_1 = src[0] + y * srcStride[0]; \
142143 const uint8_t *py_2 = py_1 + srcStride[0]; \
@@ -145,6 +146,12 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines
145146 const uint8_t av_unused *pu_2, *pv_2; \
146147 const uint8_t av_unused *pa_1, *pa_2; \
147148 unsigned int h_size = c->dstW >> 3; \
149+ if (nb_dst_planes > 1) { \
150+ dst1_1 = (dst_type *)(dst[1] + (yd) * dstStride[1]); \
151+ dst1_2 = (dst_type *)(dst[1] + (yd + 1) * dstStride[1]); \
152+ dst2_1 = (dst_type *)(dst[2] + (yd) * dstStride[2]); \
153+ dst2_2 = (dst_type *)(dst[2] + (yd + 1) * dstStride[2]); \
154+ } \
148155 if (yuv422) { \
149156 pu_2 = pu_1 + srcStride[1]; \
150157 pv_2 = pv_1 + srcStride[2]; \
@@ -156,7 +163,7 @@ const int *sws_getCoefficients(int colorspace) · 5 unmodified lines
156163 while (h_size--) { \
157164 int av_unused U, V, Y; \
158165
159−#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \
166+#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes) \
160167 pu_1 += 4 >> ss; \
161168 pv_1 += 4 >> ss; \
162169 if (yuv422) { \
@@ -171,6 +178,12 @@ const int *sws_getCoefficients(int colorspace) · 8 unmodified lines
171178 } \
172179 dst_1 += dst_delta >> ss; \
173180 dst_2 += dst_delta >> ss; \
181+ if (nb_dst_planes > 1) { \
182+ dst1_1 += dst_delta >> ss; \
183+ dst1_2 += dst_delta >> ss; \
184+ dst2_1 += dst_delta >> ss; \
185+ dst2_2 += dst_delta >> ss; \
186+ } \
174187 } \
175188 if (c->dstW & (4 >> ss)) { \
176189 int av_unused Y, U, V; \
@@ -181,8 +194,8 @@ const int *sws_getCoefficients(int colorspace) · 4 unmodified lines
181194 return srcSliceH; \
182195 }
183196
184−#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \
185− YUV2RGBFUNC(func_name, dst_type, alpha, 0) \
197+#define YUV420FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \
198+ YUV2RGBFUNC(func_name, dst_type, alpha, 0, nb_dst_planes) \
186199 LOADCHROMA(1, 0); \
187200 PUTFUNC(1, 0, abase); \
188201 PUTFUNC(2, 0, abase); \
@@ -198,7 +211,7 @@ const int *sws_getCoefficients(int colorspace) · 9 unmodified lines
198211 LOADCHROMA(1, 3); \
199212 PUTFUNC(2, 3, abase); \
200213 PUTFUNC(1, 3, abase); \
201− ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \
214+ ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes) \
202215 LOADCHROMA(1, 0); \
203216 PUTFUNC(1, 0, abase); \
204217 PUTFUNC(2, 0, abase); \
@@ -206,14 +219,14 @@ const int *sws_getCoefficients(int colorspace) · 1 unmodified line
206219 LOADCHROMA(1, 1); \
207220 PUTFUNC(2, 1, abase); \
208221 PUTFUNC(1, 1, abase); \
209− ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \
222+ ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes) \
210223 LOADCHROMA(1, 0); \
211224 PUTFUNC(1, 0, abase); \
212225 PUTFUNC(2, 0, abase); \
213226 ENDYUV2RGBFUNC()
214227
215−#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta) \
216− YUV2RGBFUNC(func_name, dst_type, alpha, 1) \
228+#define YUV422FUNC(func_name, dst_type, alpha, abase, PUTFUNC, dst_delta, nb_dst_planes) \
229+ YUV2RGBFUNC(func_name, dst_type, alpha, 1, nb_dst_planes) \
217230 LOADCHROMA(1, 0); \
218231 PUTFUNC(1, 0, abase); \
219232 \
@@ -237,7 +250,7 @@ const int *sws_getCoefficients(int colorspace) · 17 unmodified lines
237250 \
238251 LOADCHROMA(1, 3); \
239252 PUTFUNC(1, 3, abase); \
240− ENDYUV2RGBLINE(dst_delta, 0, alpha, 1) \
253+ ENDYUV2RGBLINE(dst_delta, 0, alpha, 1, nb_dst_planes) \
241254 LOADCHROMA(1, 0); \
242255 PUTFUNC(1, 0, abase); \
243256 \
@@ -249,7 +262,7 @@ const int *sws_getCoefficients(int colorspace) · 5 unmodified lines
249262 \
250263 LOADCHROMA(1, 1); \
251264 PUTFUNC(1, 1, abase); \
252− ENDYUV2RGBLINE(dst_delta, 1, alpha, 1) \
265+ ENDYUV2RGBLINE(dst_delta, 1, alpha, 1, nb_dst_planes) \
253266 LOADCHROMA(1, 0); \
254267 PUTFUNC(1, 0, abase); \
255268 \
@@ -258,7 +271,7 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines
258271 ENDYUV2RGBFUNC()
259272
260273 #define YUV420FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \
261− YUV2RGBFUNC(func_name, dst_type, 0, 0) \
274+ YUV2RGBFUNC(func_name, dst_type, 0, 0, 1) \
262275 LOADDITHER \
263276 \
264277 LOADCHROMA(1, 0); \
@@ -276,7 +289,7 @@ const int *sws_getCoefficients(int colorspace) · 11 unmodified lines
276289 LOADCHROMA(1, 3); \
277290 PUTFUNC(2, 3, 6 + 8); \
278291 PUTFUNC(1, 3, 6); \
279− ENDYUV2RGBLINE(dst_delta, 0, 0, 0) \
292+ ENDYUV2RGBLINE(dst_delta, 0, 0, 0, 1) \
280293 LOADDITHER \
281294 \
282295 LOADCHROMA(1, 0); \
@@ -286,7 +299,7 @@ const int *sws_getCoefficients(int colorspace) · 3 unmodified lines
286299 LOADCHROMA(1, 1); \
287300 PUTFUNC(2, 1, 2 + 8); \
288301 PUTFUNC(1, 1, 2); \
289− ENDYUV2RGBLINE(dst_delta, 1, 0, 0) \
302+ ENDYUV2RGBLINE(dst_delta, 1, 0, 0, 1) \
290303 LOADDITHER \
291304 \
292305 LOADCHROMA(1, 0); \
@@ -295,7 +308,7 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines
295308 ENDYUV2RGBFUNC()
296309
297310 #define YUV422FUNC_DITHER(func_name, dst_type, LOADDITHER, PUTFUNC, dst_delta) \
298− YUV2RGBFUNC(func_name, dst_type, 0, 1) \
311+ YUV2RGBFUNC(func_name, dst_type, 0, 1, 1) \
299312 LOADDITHER \
300313 \
301314 LOADCHROMA(1, 0); \
@@ -321,7 +334,7 @@ const int *sws_getCoefficients(int colorspace) · 19 unmodified lines
321334 \
322335 LOADCHROMA(1, 3); \
323336 PUTFUNC(1, 3, 6); \
324− ENDYUV2RGBLINE(dst_delta, 0, 0, 1) \
337+ ENDYUV2RGBLINE(dst_delta, 0, 0, 1, 1) \
325338 LOADDITHER \
326339 \
327340 LOADCHROMA(1, 0); \
@@ -335,7 +348,7 @@ const int *sws_getCoefficients(int colorspace) · 7 unmodified lines
335348 \
336349 LOADCHROMA(1, 1); \
337350 PUTFUNC(1, 1, 2); \
338− ENDYUV2RGBLINE(dst_delta, 1, 0, 1) \
351+ ENDYUV2RGBLINE(dst_delta, 1, 0, 1, 1) \
339352 LOADDITHER \
340353 \
341354 LOADCHROMA(1, 0); \
@@ -431,7 +444,7 @@ const int *sws_getCoefficients(int colorspace) · 89 unmodified lines
431444 g[Y + d64[1 + o]] + \
432445 b[Y + d128[1 + o]];
433446
434−YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0)
447+YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0, 1)
435448 const uint8_t *d128 = ff_dither_8x8_220[yd & 7];
436449 char out_1 = 0, out_2 = 0;
437450 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) · 56 unmodified lines
494507 ENDYUV2RGBFUNC()
495508
496509 // YUV420
497−YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48)
498−YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48)
499−YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8)
510+YUV420FUNC(yuv2rgb_c_48, uint8_t, 0, 0, PUTRGB48, 48, 1)
511+YUV420FUNC(yuv2rgb_c_bgr48, uint8_t, 0, 0, PUTBGR48, 48, 1)
512+YUV420FUNC(yuv2rgb_c_32, uint32_t, 0, 0, PUTRGB, 8, 1)
500513 #if HAVE_BIGENDIAN
501−YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8)
502−YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8)
514+YUV420FUNC(yuva2argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1)
515+YUV420FUNC(yuva2rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
503516 #else
504−YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8)
505−YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8)
517+YUV420FUNC(yuva2rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1)
518+YUV420FUNC(yuva2argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
506519 #endif
507−YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24)
508−YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24)
520+YUV420FUNC(yuv2rgb_c_24_rgb, uint8_t, 0, 0, PUTRGB24, 24, 1)
521+YUV420FUNC(yuv2rgb_c_24_bgr, uint8_t, 0, 0, PUTBGR24, 24, 1)
509522 YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8)
510523 YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8)
511524 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 · 2 unmodified lines
514527 YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8)
515528
516529 // YUV422
517−YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48)
518−YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48)
519−YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8)
530+YUV422FUNC(yuv422p_rgb48_c, uint8_t, 0, 0, PUTRGB48, 48, 1)
531+YUV422FUNC(yuv422p_bgr48_c, uint8_t, 0, 0, PUTBGR48, 48, 1)
532+YUV422FUNC(yuv422p_rgb32_c, uint32_t, 0, 0, PUTRGB, 8, 1)
520533 #if HAVE_BIGENDIAN
521−YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8)
522−YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8)
534+YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 24, PUTRGBA, 8, 1)
535+YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
523536 #else
524−YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8)
525−YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8)
537+YUV422FUNC(yuva422p_rgba_c, uint32_t, 1, 24, PUTRGBA, 8, 1)
538+YUV422FUNC(yuva422p_argb_c, uint32_t, 1, 0, PUTRGBA, 8, 1)
526539 #endif
527−YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24)
528−YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24)
540+YUV422FUNC(yuv422p_rgb24_c, uint8_t, 0, 0, PUTRGB24, 24, 1)
541+YUV422FUNC(yuv422p_bgr24_c, uint8_t, 0, 0, PUTBGR24, 24, 1)
529542 YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8)
530543 YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8)
531544 YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8)

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