Ticket #10577: 0001-swscale-output-add-support-for-AY10BE-AY10LE-pixel-v2.patch
| File 0001-swscale-output-add-support-for-AY10BE-AY10LE-pixel-v2.patch, 11.3 KB (added by , 3 years ago) |
|---|
-
libavcodec/raw.c
From 1c5c977719891b244ccde8139d25bc60b62427eb Mon Sep 17 00:00:00 2001 From: Michael Farrell <micolous+git@gmail.com> Date: Fri, 22 Sep 2023 19:18:34 +1000 Subject: [PATCH] swscale/output: add support for AY10BE/AY10LE pixel format (v2) This is a bit-packed version of YUVA422P10, used for still frames in ATEM video switchers. Signed-off-by: Michael Farrell <micolous+git@gmail.com> --- libavcodec/raw.c | 2 ++ libavformat/riff.c | 2 ++ libavutil/pixdesc.c | 26 +++++++++++++++ libavutil/pixfmt.h | 4 +++ libswscale/input.c | 79 +++++++++++++++++++++++++++++++++++++++++++++ libswscale/output.c | 70 +++++++++++++++++++++++++++++++++++++++ libswscale/utils.c | 2 ++ 7 files changed, 185 insertions(+) diff --git a/libavcodec/raw.c b/libavcodec/raw.c index 1e5b48d1e0..6cb02173f0 100644
a b static const PixelFormatTag raw_pix_fmt_tags[] = { 73 73 { AV_PIX_FMT_NV12, MKTAG('N', 'V', '1', '2') }, 74 74 { AV_PIX_FMT_NV21, MKTAG('N', 'V', '2', '1') }, 75 75 { AV_PIX_FMT_VUYA, MKTAG('A', 'Y', 'U', 'V') }, /* MS 4:4:4:4 */ 76 { AV_PIX_FMT_AY10BE, MKTAG('Y', 'A', '1', '0') }, /* ATEM */ 77 { AV_PIX_FMT_AY10LE, MKTAG('0', '1', 'A', 'Y') }, /* ATEM */ 76 78 77 79 /* nut */ 78 80 { AV_PIX_FMT_RGB555LE, MKTAG('R', 'G', 'B', 15) }, -
libavformat/riff.c
diff --git a/libavformat/riff.c b/libavformat/riff.c index 97708df6e3..c58f5c0446 100644
a b const AVCodecTag ff_codec_bmp_tags[] = { 503 503 { AV_CODEC_ID_VQC, MKTAG('V', 'Q', 'C', '2') }, 504 504 { AV_CODEC_ID_RTV1, MKTAG('R', 'T', 'V', '1') }, 505 505 { AV_CODEC_ID_VMIX, MKTAG('V', 'M', 'X', '1') }, 506 { AV_CODEC_ID_RAWVIDEO, MKTAG('0', '1', 'y', 'a') }, 507 { AV_CODEC_ID_RAWVIDEO, MKTAG('a', 'y', '1', '0') }, 506 508 { AV_CODEC_ID_NONE, 0 } 507 509 }; 508 510 -
libavutil/pixdesc.c
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index e1e0dd2a9e..bd6566cf82 100644
a b static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { 2765 2765 }, 2766 2766 .flags = AV_PIX_FMT_FLAG_PLANAR, 2767 2767 }, 2768 [AV_PIX_FMT_AY10BE] = { 2769 .name = "ay10be", 2770 .nb_components = 4, 2771 .log2_chroma_w = 1, 2772 .log2_chroma_h = 0, 2773 .comp = { 2774 { 0, 4, 0, 0, 10 }, /* Y */ 2775 { 0, 8, 1, 2, 10 }, /* U */ 2776 { 0, 8, 5, 2, 10 }, /* V */ 2777 { 0, 4, 2, 4, 10 }, /* A */ 2778 }, 2779 .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, 2780 }, 2781 [AV_PIX_FMT_AY10LE] = { 2782 .name = "ay10le", 2783 .nb_components = 4, 2784 .log2_chroma_w = 1, 2785 .log2_chroma_h = 0, 2786 .comp = { 2787 { 0, 4, 0, 0, 10 }, /* Y */ 2788 { 0, 8, 1, 2, 10 }, /* U */ 2789 { 0, 8, 5, 2, 10 }, /* V */ 2790 { 0, 4, 2, 4, 10 }, /* A */ 2791 }, 2792 .flags = AV_PIX_FMT_FLAG_ALPHA, 2793 }, 2768 2794 }; 2769 2795 2770 2796 static const char * const color_range_names[] = { -
libavutil/pixfmt.h
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 63e07ba64f..21c8244e41 100644
a b enum AVPixelFormat { 426 426 AV_PIX_FMT_P412BE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian 427 427 AV_PIX_FMT_P412LE, ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian 428 428 429 AV_PIX_FMT_AY10BE, ///< packed YUVA 4:2:2 like YUVA422P10, 32bpp, (msb)2X 10A 10U/V 10Y(lsb), big-endian 430 AV_PIX_FMT_AY10LE, ///< packed YUVA 4:2:2 like YUVA422P10, 32bpp, (msb)2X 10A 10U/V 10Y(lsb), little-endian 431 429 432 AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions 430 433 }; 431 434 … … enum AVPixelFormat { 533 536 534 537 #define AV_PIX_FMT_RGBF32 AV_PIX_FMT_NE(RGBF32BE, RGBF32LE) 535 538 #define AV_PIX_FMT_RGBAF32 AV_PIX_FMT_NE(RGBAF32BE, RGBAF32LE) 539 #define AV_PIX_FMT_AY10 AV_PIX_FMT_NE(AY10BE, AY10LE) 536 540 537 541 /** 538 542 * Chromaticity coordinates of the source primaries. -
libswscale/input.c
diff --git a/libswscale/input.c b/libswscale/input.c index 41795c636e..35b9617628 100644
a b static void rgbaf16##endian_name##ToA_c(uint8_t *_dst, const uint8_t *_src, cons 1284 1284 rgbaf16_funcs_endian(le, 0) 1285 1285 rgbaf16_funcs_endian(be, 1) 1286 1286 1287 static void ay10be_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, 1288 const uint8_t *unused1, int width, uint32_t *unused2, 1289 void *opq) 1290 { 1291 int i; 1292 for (i = 0; i < width; i++) 1293 AV_WN16(dst + i * 2, AV_RB32(src + i * 4) & 0x3FFu); 1294 } 1295 1296 1297 static void ay10be_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 1298 const uint8_t *src, const uint8_t *unused1, int width, 1299 uint32_t *unused2, void *opq) 1300 { 1301 int i; 1302 for (i = 0; i < width; i++) { 1303 AV_WN16(dstU + i * 2, (AV_RB32(src + i * 8) >> 10) & 0x3FFu); 1304 AV_WN16(dstV + i * 2, (AV_RB32(src + i * 8 + 4) >> 10) & 0x3FFu); 1305 } 1306 } 1307 1308 static void ay10be_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, 1309 const uint8_t *unused1, int width, uint32_t *unused2, 1310 void *opq) 1311 { 1312 int i; 1313 for (i = 0; i < width; i++) 1314 AV_WN16(dst + i * 2, (AV_RB32(src + i * 4) >> 20) & 0x3FFu); 1315 } 1316 1317 1318 static void ay10le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, 1319 const uint8_t *unused1, int width, uint32_t *unused2, 1320 void *opq) 1321 { 1322 int i; 1323 for (i = 0; i < width; i++) 1324 AV_WN16(dst + i * 2, AV_RL32(src + i * 4) & 0x3FFu); 1325 } 1326 1327 1328 static void ay10le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 1329 const uint8_t *src, const uint8_t *unused1, int width, 1330 uint32_t *unused2, void *opq) 1331 { 1332 int i; 1333 for (i = 0; i < width; i++) { 1334 AV_WN16(dstU + i * 2, (AV_RL32(src + i * 8) >> 10) & 0x3FFu); 1335 AV_WN16(dstV + i * 2, (AV_RL32(src + i * 8 + 4) >> 10) & 0x3FFu); 1336 } 1337 } 1338 1339 static void ay10le_A_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused0, 1340 const uint8_t *unused1, int width, uint32_t *unused2, 1341 void *opq) 1342 { 1343 int i; 1344 for (i = 0; i < width; i++) 1345 AV_WN16(dst + i * 2, (AV_RL32(src + i * 4) >> 20) & 0x3FFu); 1346 } 1347 1287 1348 av_cold void ff_sws_init_input_funcs(SwsContext *c) 1288 1349 { 1289 1350 enum AVPixelFormat srcFormat = c->srcFormat; … … av_cold void ff_sws_init_input_funcs(SwsContext *c) 1477 1538 case AV_PIX_FMT_Y212LE: 1478 1539 c->chrToYV12 = y212le_UV_c; 1479 1540 break; 1541 case AV_PIX_FMT_AY10BE: 1542 c->chrToYV12 = ay10be_UV_c; 1543 break; 1544 case AV_PIX_FMT_AY10LE: 1545 c->chrToYV12 = ay10le_UV_c; 1546 break; 1480 1547 } 1481 1548 if (c->chrSrcHSubSample) { 1482 1549 switch (srcFormat) { … … av_cold void ff_sws_init_input_funcs(SwsContext *c) 1981 2048 case AV_PIX_FMT_RGBAF16LE: 1982 2049 c->lumToYV12 = rgbaf16leToY_c; 1983 2050 break; 2051 case AV_PIX_FMT_AY10BE: 2052 c->lumToYV12 = ay10be_Y_c; 2053 break; 2054 case AV_PIX_FMT_AY10LE: 2055 c->lumToYV12 = ay10le_Y_c; 2056 break; 1984 2057 } 1985 2058 if (c->needAlpha) { 1986 2059 if (is16BPS(srcFormat) || isNBPS(srcFormat)) { … … av_cold void ff_sws_init_input_funcs(SwsContext *c) 2024 2097 case AV_PIX_FMT_PAL8 : 2025 2098 c->alpToYV12 = palToA_c; 2026 2099 break; 2100 case AV_PIX_FMT_AY10BE: 2101 c->alpToYV12 = ay10be_A_c; 2102 break; 2103 case AV_PIX_FMT_AY10LE: 2104 c->alpToYV12 = ay10le_A_c; 2105 break; 2027 2106 } 2028 2107 } 2029 2108 } -
libswscale/output.c
diff --git a/libswscale/output.c b/libswscale/output.c index 5c85bff971..66794a4816 100644
a b yuv2y2xx_wrapper(12) 2787 2787 2788 2788 #undef output_pixel 2789 2789 2790 static void 2791 yuv2ay10_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, 2792 int lumFilterSize, const int16_t *chrFilter, 2793 const int16_t **chrUSrc, const int16_t **chrVSrc, 2794 int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, 2795 int dstW, int y, int big_endian) 2796 { 2797 int i, j; 2798 2799 for (i = 0; i < ((dstW + 1) >> 1); i++) { 2800 int Y1 = 1 << 16, U = 1 << 16, A1 = 1 << 16; 2801 int Y2 = 1 << 16, V = 1 << 16, A2 = 1 << 16; 2802 2803 for (j = 0; j < lumFilterSize; j++) { 2804 Y1 += lumSrc[j][i * 2] * lumFilter[j]; 2805 Y2 += lumSrc[j][i * 2 + 1] * lumFilter[j]; 2806 A1 += alpSrc[j][i * 2] * lumFilter[j]; 2807 A2 += alpSrc[j][i * 2 + 1] * lumFilter[j]; 2808 } 2809 2810 for (j = 0; j < chrFilterSize; j++) { 2811 U += chrUSrc[j][i] * chrFilter[j]; 2812 V += chrVSrc[j][i] * chrFilter[j]; 2813 } 2814 2815 Y1 = av_clip_uintp2(Y1 >> 17, 10); 2816 U = av_clip_uintp2(U >> 17, 10); 2817 A1 = av_clip_uintp2(A1 >> 17, 10); 2818 Y2 = av_clip_uintp2(Y2 >> 17, 10); 2819 V = av_clip_uintp2(V >> 17, 10); 2820 A2 = av_clip_uintp2(A2 >> 17, 10); 2821 2822 if (big_endian) { 2823 AV_WB32(dest + 8 * i, Y1 | U << 10 | A1 << 20); 2824 AV_WB32(dest + 8 * i + 4, Y2 | V << 10 | A2 << 20); 2825 } else { 2826 AV_WL32(dest + 8 * i, Y1 | U << 10 | A1 << 20); 2827 AV_WL32(dest + 8 * i + 4, Y2 | V << 10 | A2 << 20); 2828 } 2829 } 2830 } 2831 2832 static void 2833 yuv2ay10be_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, 2834 int lumFilterSize, const int16_t *chrFilter, 2835 const int16_t **chrUSrc, const int16_t **chrVSrc, 2836 int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, 2837 int dstW, int y) 2838 { 2839 yuv2ay10_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrUSrc, 2840 chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 1); 2841 } 2842 2843 static void 2844 yuv2ay10le_X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, 2845 int lumFilterSize, const int16_t *chrFilter, 2846 const int16_t **chrUSrc, const int16_t **chrVSrc, 2847 int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, 2848 int dstW, int y) 2849 { 2850 yuv2ay10_X_c(c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrUSrc, 2851 chrVSrc, chrFilterSize, alpSrc, dest, dstW, y, 0); 2852 } 2853 2790 2854 av_cold void ff_sws_init_output_funcs(SwsContext *c, 2791 2855 yuv2planar1_fn *yuv2plane1, 2792 2856 yuv2planarX_fn *yuv2planeX, … … av_cold void ff_sws_init_output_funcs(SwsContext *c, 3313 3377 case AV_PIX_FMT_Y212LE: 3314 3378 *yuv2packedX = yuv2y212le_X_c; 3315 3379 break; 3380 case AV_PIX_FMT_AY10BE: 3381 *yuv2packedX = yuv2ay10be_X_c; 3382 break; 3383 case AV_PIX_FMT_AY10LE: 3384 *yuv2packedX = yuv2ay10le_X_c; 3385 break; 3316 3386 } 3317 3387 } -
libswscale/utils.c
diff --git a/libswscale/utils.c b/libswscale/utils.c index b3cc74331f..1148480999 100644
a b static const FormatEntry format_entries[] = { 265 265 [AV_PIX_FMT_RGBAF16LE] = { 1, 0 }, 266 266 [AV_PIX_FMT_XV30LE] = { 1, 1 }, 267 267 [AV_PIX_FMT_XV36LE] = { 1, 1 }, 268 [AV_PIX_FMT_AY10BE] = { 1, 1 }, 269 [AV_PIX_FMT_AY10LE] = { 1, 1 }, 268 270 }; 269 271 270 272 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
