Ticket #10577: 0001-swscale-output-add-support-for-AY10BE-AY10LE-pixel-f.patch
| File 0001-swscale-output-add-support-for-AY10BE-AY10LE-pixel-f.patch, 8.1 KB (added by , 3 years ago) |
|---|
-
libavcodec/raw.c
From 8d29539ce0c581537e4df175892de5166cdb263a Mon Sep 17 00:00:00 2001 From: Michael Farrell <micolous+git@gmail.com> Date: Fri, 22 Sep 2023 17:15:47 +1000 Subject: [PATCH] swscale/output: add support for AY10BE/AY10LE pixel format 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/utils.c | 2 ++ 6 files changed, 115 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/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,
