This will be used in the upcoming yuv42{0,2}p -> gbrp unscaled colorspace converters. There is no difference in performance.
Unified · Split
| @@ -124,7 +124,7 @@ const int *sws_getCoefficients(int colorspace) · 123 unmodified lines | ||
| 124 | 124 | dst_##l[12 * i + 8] = dst_##l[12 * i + 9] = g[Y]; \ |
| 125 | 125 | dst_##l[12 * i + 10] = dst_##l[12 * i + 11] = r[Y]; |
| 126 | 126 | |
| 127 | −#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422) \ | |
| 127 | +#define YUV2RGBFUNC(func_name, dst_type, alpha, yuv422, nb_dst_planes) \ | |
| 128 | 128 | static int func_name(SwsContext *c, const uint8_t *src[], \ |
| 129 | 129 | int srcStride[], int srcSliceY, int srcSliceH, \ |
| 130 | 130 | uint8_t *dst[], int dstStride[]) \ |
| @@ -137,6 +137,7 @@ const int *sws_getCoefficients(int colorspace) · 6 unmodified lines | ||
| 137 | 137 | (dst_type *)(dst[0] + (yd) * dstStride[0]); \ |
| 138 | 138 | dst_type *dst_2 = \ |
| 139 | 139 | (dst_type *)(dst[0] + (yd + 1) * dstStride[0]); \ |
| 140 | + dst_type av_unused *dst1_1, *dst1_2, *dst2_1, *dst2_2; \ | |
| 140 | 141 | dst_type av_unused *r, *g, *b; \ |
| 141 | 142 | const uint8_t *py_1 = src[0] + y * srcStride[0]; \ |
| 142 | 143 | const uint8_t *py_2 = py_1 + srcStride[0]; \ |
| @@ -145,6 +146,12 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines | ||
| 145 | 146 | const uint8_t av_unused *pu_2, *pv_2; \ |
| 146 | 147 | const uint8_t av_unused *pa_1, *pa_2; \ |
| 147 | 148 | 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 | + } \ | |
| 148 | 155 | if (yuv422) { \ |
| 149 | 156 | pu_2 = pu_1 + srcStride[1]; \ |
| 150 | 157 | pv_2 = pv_1 + srcStride[2]; \ |
| @@ -156,7 +163,7 @@ const int *sws_getCoefficients(int colorspace) · 5 unmodified lines | ||
| 156 | 163 | while (h_size--) { \ |
| 157 | 164 | int av_unused U, V, Y; \ |
| 158 | 165 | |
| 159 | −#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422) \ | |
| 166 | +#define ENDYUV2RGBLINE(dst_delta, ss, alpha, yuv422, nb_dst_planes) \ | |
| 160 | 167 | pu_1 += 4 >> ss; \ |
| 161 | 168 | pv_1 += 4 >> ss; \ |
| 162 | 169 | if (yuv422) { \ |
| @@ -171,6 +178,12 @@ const int *sws_getCoefficients(int colorspace) · 8 unmodified lines | ||
| 171 | 178 | } \ |
| 172 | 179 | dst_1 += dst_delta >> ss; \ |
| 173 | 180 | 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 | + } \ | |
| 174 | 187 | } \ |
| 175 | 188 | if (c->dstW & (4 >> ss)) { \ |
| 176 | 189 | int av_unused Y, U, V; \ |
| @@ -181,8 +194,8 @@ const int *sws_getCoefficients(int colorspace) · 4 unmodified lines | ||
| 181 | 194 | return srcSliceH; \ |
| 182 | 195 | } |
| 183 | 196 | |
| 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) \ | |
| 186 | 199 | LOADCHROMA(1, 0); \ |
| 187 | 200 | PUTFUNC(1, 0, abase); \ |
| 188 | 201 | PUTFUNC(2, 0, abase); \ |
| @@ -198,7 +211,7 @@ const int *sws_getCoefficients(int colorspace) · 9 unmodified lines | ||
| 198 | 211 | LOADCHROMA(1, 3); \ |
| 199 | 212 | PUTFUNC(2, 3, abase); \ |
| 200 | 213 | PUTFUNC(1, 3, abase); \ |
| 201 | − ENDYUV2RGBLINE(dst_delta, 0, alpha, 0) \ | |
| 214 | + ENDYUV2RGBLINE(dst_delta, 0, alpha, 0, nb_dst_planes) \ | |
| 202 | 215 | LOADCHROMA(1, 0); \ |
| 203 | 216 | PUTFUNC(1, 0, abase); \ |
| 204 | 217 | PUTFUNC(2, 0, abase); \ |
| @@ -206,14 +219,14 @@ const int *sws_getCoefficients(int colorspace) · 1 unmodified line | ||
| 206 | 219 | LOADCHROMA(1, 1); \ |
| 207 | 220 | PUTFUNC(2, 1, abase); \ |
| 208 | 221 | PUTFUNC(1, 1, abase); \ |
| 209 | − ENDYUV2RGBLINE(dst_delta, 1, alpha, 0) \ | |
| 222 | + ENDYUV2RGBLINE(dst_delta, 1, alpha, 0, nb_dst_planes) \ | |
| 210 | 223 | LOADCHROMA(1, 0); \ |
| 211 | 224 | PUTFUNC(1, 0, abase); \ |
| 212 | 225 | PUTFUNC(2, 0, abase); \ |
| 213 | 226 | ENDYUV2RGBFUNC() |
| 214 | 227 | |
| 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) \ | |
| 217 | 230 | LOADCHROMA(1, 0); \ |
| 218 | 231 | PUTFUNC(1, 0, abase); \ |
| 219 | 232 | \ |
| @@ -237,7 +250,7 @@ const int *sws_getCoefficients(int colorspace) · 17 unmodified lines | ||
| 237 | 250 | \ |
| 238 | 251 | LOADCHROMA(1, 3); \ |
| 239 | 252 | PUTFUNC(1, 3, abase); \ |
| 240 | − ENDYUV2RGBLINE(dst_delta, 0, alpha, 1) \ | |
| 253 | + ENDYUV2RGBLINE(dst_delta, 0, alpha, 1, nb_dst_planes) \ | |
| 241 | 254 | LOADCHROMA(1, 0); \ |
| 242 | 255 | PUTFUNC(1, 0, abase); \ |
| 243 | 256 | \ |
| @@ -249,7 +262,7 @@ const int *sws_getCoefficients(int colorspace) · 5 unmodified lines | ||
| 249 | 262 | \ |
| 250 | 263 | LOADCHROMA(1, 1); \ |
| 251 | 264 | PUTFUNC(1, 1, abase); \ |
| 252 | − ENDYUV2RGBLINE(dst_delta, 1, alpha, 1) \ | |
| 265 | + ENDYUV2RGBLINE(dst_delta, 1, alpha, 1, nb_dst_planes) \ | |
| 253 | 266 | LOADCHROMA(1, 0); \ |
| 254 | 267 | PUTFUNC(1, 0, abase); \ |
| 255 | 268 | \ |
| @@ -258,7 +271,7 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines | ||
| 258 | 271 | ENDYUV2RGBFUNC() |
| 259 | 272 | |
| 260 | 273 | #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) \ | |
| 262 | 275 | LOADDITHER \ |
| 263 | 276 | \ |
| 264 | 277 | LOADCHROMA(1, 0); \ |
| @@ -276,7 +289,7 @@ const int *sws_getCoefficients(int colorspace) · 11 unmodified lines | ||
| 276 | 289 | LOADCHROMA(1, 3); \ |
| 277 | 290 | PUTFUNC(2, 3, 6 + 8); \ |
| 278 | 291 | PUTFUNC(1, 3, 6); \ |
| 279 | − ENDYUV2RGBLINE(dst_delta, 0, 0, 0) \ | |
| 292 | + ENDYUV2RGBLINE(dst_delta, 0, 0, 0, 1) \ | |
| 280 | 293 | LOADDITHER \ |
| 281 | 294 | \ |
| 282 | 295 | LOADCHROMA(1, 0); \ |
| @@ -286,7 +299,7 @@ const int *sws_getCoefficients(int colorspace) · 3 unmodified lines | ||
| 286 | 299 | LOADCHROMA(1, 1); \ |
| 287 | 300 | PUTFUNC(2, 1, 2 + 8); \ |
| 288 | 301 | PUTFUNC(1, 1, 2); \ |
| 289 | − ENDYUV2RGBLINE(dst_delta, 1, 0, 0) \ | |
| 302 | + ENDYUV2RGBLINE(dst_delta, 1, 0, 0, 1) \ | |
| 290 | 303 | LOADDITHER \ |
| 291 | 304 | \ |
| 292 | 305 | LOADCHROMA(1, 0); \ |
| @@ -295,7 +308,7 @@ const int *sws_getCoefficients(int colorspace) · 2 unmodified lines | ||
| 295 | 308 | ENDYUV2RGBFUNC() |
| 296 | 309 | |
| 297 | 310 | #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) \ | |
| 299 | 312 | LOADDITHER \ |
| 300 | 313 | \ |
| 301 | 314 | LOADCHROMA(1, 0); \ |
| @@ -321,7 +334,7 @@ const int *sws_getCoefficients(int colorspace) · 19 unmodified lines | ||
| 321 | 334 | \ |
| 322 | 335 | LOADCHROMA(1, 3); \ |
| 323 | 336 | PUTFUNC(1, 3, 6); \ |
| 324 | − ENDYUV2RGBLINE(dst_delta, 0, 0, 1) \ | |
| 337 | + ENDYUV2RGBLINE(dst_delta, 0, 0, 1, 1) \ | |
| 325 | 338 | LOADDITHER \ |
| 326 | 339 | \ |
| 327 | 340 | LOADCHROMA(1, 0); \ |
| @@ -335,7 +348,7 @@ const int *sws_getCoefficients(int colorspace) · 7 unmodified lines | ||
| 335 | 348 | \ |
| 336 | 349 | LOADCHROMA(1, 1); \ |
| 337 | 350 | PUTFUNC(1, 1, 2); \ |
| 338 | − ENDYUV2RGBLINE(dst_delta, 1, 0, 1) \ | |
| 351 | + ENDYUV2RGBLINE(dst_delta, 1, 0, 1, 1) \ | |
| 339 | 352 | LOADDITHER \ |
| 340 | 353 | \ |
| 341 | 354 | LOADCHROMA(1, 0); \ |
| @@ -431,7 +444,7 @@ const int *sws_getCoefficients(int colorspace) · 89 unmodified lines | ||
| 431 | 444 | g[Y + d64[1 + o]] + \ |
| 432 | 445 | b[Y + d128[1 + o]]; |
| 433 | 446 | |
| 434 | −YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0) | |
| 447 | +YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0, 0, 1) | |
| 435 | 448 | const uint8_t *d128 = ff_dither_8x8_220[yd & 7]; |
| 436 | 449 | char out_1 = 0, out_2 = 0; |
| 437 | 450 | 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 | ||
| 494 | 507 | ENDYUV2RGBFUNC() |
| 495 | 508 | |
| 496 | 509 | // 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) | |
| 500 | 513 | #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) | |
| 503 | 516 | #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) | |
| 506 | 519 | #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) | |
| 509 | 522 | YUV420FUNC_DITHER(yuv2rgb_c_16_ordered_dither, uint16_t, LOADDITHER16, PUTRGB16, 8) |
| 510 | 523 | YUV420FUNC_DITHER(yuv2rgb_c_15_ordered_dither, uint16_t, LOADDITHER15, PUTRGB15, 8) |
| 511 | 524 | 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 | ||
| 514 | 527 | YUV420FUNC_DITHER(yuv2rgb_c_4b_ordered_dither, uint8_t, LOADDITHER4DB, PUTRGB4DB, 8) |
| 515 | 528 | |
| 516 | 529 | // 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) | |
| 520 | 533 | #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) | |
| 523 | 536 | #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) | |
| 526 | 539 | #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) | |
| 529 | 542 | YUV422FUNC_DITHER(yuv422p_bgr16, uint16_t, LOADDITHER16, PUTRGB16, 8) |
| 530 | 543 | YUV422FUNC_DITHER(yuv422p_bgr15, uint16_t, LOADDITHER15, PUTRGB15, 8) |
| 531 | 544 | YUV422FUNC_DITHER(yuv422p_bgr12, uint16_t, LOADDITHER12, PUTRGB12, 8) |