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 micolous, 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[] = {  
    7373    { AV_PIX_FMT_NV12,    MKTAG('N', 'V', '1', '2') },
    7474    { AV_PIX_FMT_NV21,    MKTAG('N', 'V', '2', '1') },
    7575    { 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 */
    7678
    7779    /* nut */
    7880    { 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[] = {  
    503503    { AV_CODEC_ID_VQC,          MKTAG('V', 'Q', 'C', '2') },
    504504    { AV_CODEC_ID_RTV1,         MKTAG('R', 'T', 'V', '1') },
    505505    { 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') },
    506508    { AV_CODEC_ID_NONE,         0 }
    507509};
    508510
  • 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] = {  
    27652765        },
    27662766        .flags = AV_PIX_FMT_FLAG_PLANAR,
    27672767    },
     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    },
    27682794};
    27692795
    27702796static 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 {  
    426426    AV_PIX_FMT_P412BE,      ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, big-endian
    427427    AV_PIX_FMT_P412LE,      ///< interleaved chroma YUV 4:4:4, 36bpp, data in the high bits, little-endian
    428428
     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
    429432    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
    430433};
    431434
    enum AVPixelFormat {  
    533536
    534537#define AV_PIX_FMT_RGBF32     AV_PIX_FMT_NE(RGBF32BE, RGBF32LE)
    535538#define AV_PIX_FMT_RGBAF32    AV_PIX_FMT_NE(RGBAF32BE, RGBAF32LE)
     539#define AV_PIX_FMT_AY10       AV_PIX_FMT_NE(AY10BE, AY10LE)
    536540
    537541/**
    538542  * 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  
    12841284rgbaf16_funcs_endian(le, 0)
    12851285rgbaf16_funcs_endian(be, 1)
    12861286
     1287static 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
     1297static 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
     1308static 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
     1318static 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
     1328static 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
     1339static 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
    12871348av_cold void ff_sws_init_input_funcs(SwsContext *c)
    12881349{
    12891350    enum AVPixelFormat srcFormat = c->srcFormat;
    av_cold void ff_sws_init_input_funcs(SwsContext *c)  
    14771538    case AV_PIX_FMT_Y212LE:
    14781539        c->chrToYV12 = y212le_UV_c;
    14791540        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;
    14801547    }
    14811548    if (c->chrSrcHSubSample) {
    14821549        switch (srcFormat) {
    av_cold void ff_sws_init_input_funcs(SwsContext *c)  
    19812048    case AV_PIX_FMT_RGBAF16LE:
    19822049        c->lumToYV12 = rgbaf16leToY_c;
    19832050        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;
    19842057    }
    19852058    if (c->needAlpha) {
    19862059        if (is16BPS(srcFormat) || isNBPS(srcFormat)) {
    av_cold void ff_sws_init_input_funcs(SwsContext *c)  
    20242097        case AV_PIX_FMT_PAL8 :
    20252098            c->alpToYV12 = palToA_c;
    20262099            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;
    20272106        }
    20282107    }
    20292108}
  • libswscale/utils.c

    diff --git a/libswscale/utils.c b/libswscale/utils.c
    index b3cc74331f..1148480999 100644
    a b static const FormatEntry format_entries[] = {  
    265265    [AV_PIX_FMT_RGBAF16LE]   = { 1, 0 },
    266266    [AV_PIX_FMT_XV30LE]      = { 1, 1 },
    267267    [AV_PIX_FMT_XV36LE]      = { 1, 1 },
     268    [AV_PIX_FMT_AY10BE]      = { 1, 1 },
     269    [AV_PIX_FMT_AY10LE]      = { 1, 1 },
    268270};
    269271
    270272int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,