static int mov_rewrite_dvd_sub_extradata(AVStream *st)

{

    char pal_s[256];

    char buf[256];

    int pal_s_pos = 0;

    uint8_t *src = st->codec->extradata;

    int i;



    if (st->codec->extradata_size != 64)

        return 0;



    for (i = 0; i < 16; i++) {

        uint32_t yuv = AV_RB32(src + i * 4);

        uint32_t rgba = yuv_to_rgba(yuv);



        snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, "%06x%s", rgba,

                 i != 15 ? ", " : "");

        pal_s_pos = strlen(pal_s);

        if (pal_s_pos >= sizeof(pal_s))

            return 0;

    }



    snprintf(buf, sizeof(buf), "size: %dx%d\npalette: %s\n",

             st->codec->width, st->codec->height, pal_s);



    av_freep(&st->codec->extradata);

    st->codec->extradata_size = 0;

    st->codec->extradata = av_mallocz(strlen(buf) + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!st->codec->extradata)

        return AVERROR(ENOMEM);

    st->codec->extradata_size = strlen(buf);

    memcpy(st->codec->extradata, buf, st->codec->extradata_size);



    return 0;

}

static int mov_rewrite_dvd_sub_extradata(AVStream *st)

{

    char pal_s[256];

    char buf[256];

    int pal_s_pos = 0;

    uint8_t *src = st->codec->extradata;

    int i;



    if (st->codec->extradata_size != 64)

        return 0;



    for (i = 0; i < 16; i++) {

        uint32_t yuv = AV_RB32(src + i * 4);

        uint32_t rgba = yuv_to_rgba(yuv);



        snprintf(pal_s + pal_s_pos, sizeof(pal_s) - pal_s_pos, "%06x%s", rgba,

                 i != 15 ? ", " : "");

        pal_s_pos = strlen(pal_s);

        if (pal_s_pos >= sizeof(pal_s))

            return 0;

    }



    snprintf(buf, sizeof(buf), "size: %dx%d\npalette: %s\n",

             st->codec->width, st->codec->height, pal_s);



    av_freep(&st->codec->extradata);

    st->codec->extradata_size = 0;

    st->codec->extradata = av_mallocz(strlen(buf) + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!st->codec->extradata)

        return AVERROR(ENOMEM);

    st->codec->extradata_size = strlen(buf);

    memcpy(st->codec->extradata, buf, st->codec->extradata_size);



    return 0;

}

static int FUNC_0(AVStream *VAR_0)

{

    char VAR_1[256];

    char VAR_2[256];

    int VAR_3 = 0;

    uint8_t *src = VAR_0->codec->extradata;

    int VAR_4;



    if (VAR_0->codec->extradata_size != 64)

        return 0;



    for (VAR_4 = 0; VAR_4 < 16; VAR_4++) {

        uint32_t yuv = AV_RB32(src + VAR_4 * 4);

        uint32_t rgba = yuv_to_rgba(yuv);



        snprintf(VAR_1 + VAR_3, sizeof(VAR_1) - VAR_3, "%06x%s", rgba,

                 VAR_4 != 15 ? ", " : "");

        VAR_3 = strlen(VAR_1);

        if (VAR_3 >= sizeof(VAR_1))

            return 0;

    }



    snprintf(VAR_2, sizeof(VAR_2), "size: %dx%d\npalette: %s\n",

             VAR_0->codec->width, VAR_0->codec->height, VAR_1);



    av_freep(&VAR_0->codec->extradata);

    VAR_0->codec->extradata_size = 0;

    VAR_0->codec->extradata = av_mallocz(strlen(VAR_2) + FF_INPUT_BUFFER_PADDING_SIZE);

    if (!VAR_0->codec->extradata)

        return AVERROR(ENOMEM);

    VAR_0->codec->extradata_size = strlen(VAR_2);

    memcpy(VAR_0->codec->extradata, VAR_2, VAR_0->codec->extradata_size);



    return 0;

}

static int FUNC_0(AVStream *VAR_0)
{ char VAR_1[256]; char VAR_2[256]; int VAR_3 = 0; uint8_t *src = VAR_0->codec->extradata; int VAR_4; if (VAR_0->codec->extradata_size != 64)
return 0; for (VAR_4 = 0; VAR_4 < 16; VAR_4++) { uint32_t yuv = AV_RB32(src + VAR_4 * 4); uint32_t rgba = yuv_to_rgba(yuv); snprintf(VAR_1 + VAR_3, sizeof(VAR_1) - VAR_3, "%06x%s", rgba,
VAR_4 != 15 ? ", " : ""); VAR_3 = strlen(VAR_1); if (VAR_3 >= sizeof(VAR_1))
return 0; } snprintf(VAR_2, sizeof(VAR_2), "size: %dx%d\npalette: %s\n",
VAR_0->codec->width, VAR_0->codec->height, VAR_1); av_freep(&VAR_0->codec->extradata); VAR_0->codec->extradata_size = 0; VAR_0->codec->extradata = av_mallocz(strlen(VAR_2) + FF_INPUT_BUFFER_PADDING_SIZE); if (!VAR_0->codec->extradata)
return AVERROR(ENOMEM); VAR_0->codec->extradata_size = strlen(VAR_2); memcpy(VAR_0->codec->extradata, VAR_2, VAR_0->codec->extradata_size); return 0; }