static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    char color_parameter_type[5] = { 0 };

    int color_primaries, color_trc, color_matrix;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams - 1];



    avio_read(pb, color_parameter_type, 4);

    if (strncmp(color_parameter_type, "nclx", 4) &&

        strncmp(color_parameter_type, "nclc", 4)) {

        av_log(c->fc, AV_LOG_WARNING, "unsupported color_parameter_type %s\n",

               color_parameter_type);

        return 0;

    }



    color_primaries = avio_rb16(pb);

    color_trc = avio_rb16(pb);

    color_matrix = avio_rb16(pb);



    av_log(c->fc, AV_LOG_TRACE,

           "%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",

           color_parameter_type, color_primaries, color_trc, color_matrix);



    if (!strncmp(color_parameter_type, "nclx", 4)) {

        uint8_t color_range = avio_r8(pb) >> 7;

        av_log(c->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);

        if (color_range)

            st->codec->color_range = AVCOL_RANGE_JPEG;

        else

            st->codec->color_range = AVCOL_RANGE_MPEG;

        /* 14496-12 references JPEG XR specs (rather than the more complete

         * 23001-8) so some adjusting is required */

        if (color_primaries >= AVCOL_PRI_FILM)

            color_primaries = AVCOL_PRI_UNSPECIFIED;

        if ((color_trc >= AVCOL_TRC_LINEAR &&

             color_trc <= AVCOL_TRC_LOG_SQRT) ||

            color_trc >= AVCOL_TRC_BT2020_10)

            color_trc = AVCOL_TRC_UNSPECIFIED;

        if (color_matrix >= AVCOL_SPC_BT2020_NCL)

            color_matrix = AVCOL_SPC_UNSPECIFIED;

        st->codec->color_primaries = color_primaries;

        st->codec->color_trc = color_trc;

        st->codec->colorspace = color_matrix;

    } else if (!strncmp(color_parameter_type, "nclc", 4)) {

        /* color primaries, Table 4-4 */

        switch (color_primaries) {

        case 1: st->codec->color_primaries = AVCOL_PRI_BT709; break;

        case 5: st->codec->color_primaries = AVCOL_PRI_SMPTE170M; break;

        case 6: st->codec->color_primaries = AVCOL_PRI_SMPTE240M; break;

        }

        /* color transfer, Table 4-5 */

        switch (color_trc) {

        case 1: st->codec->color_trc = AVCOL_TRC_BT709; break;

        case 7: st->codec->color_trc = AVCOL_TRC_SMPTE240M; break;

        }

        /* color matrix, Table 4-6 */

        switch (color_matrix) {

        case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;

        case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;

        case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;

        }

    }

    av_log(c->fc, AV_LOG_TRACE, "\n");



    return 0;

}

static int mov_read_colr(MOVContext *c, AVIOContext *pb, MOVAtom atom)

{

    AVStream *st;

    char color_parameter_type[5] = { 0 };

    int color_primaries, color_trc, color_matrix;



    if (c->fc->nb_streams < 1)

        return 0;

    st = c->fc->streams[c->fc->nb_streams - 1];



    avio_read(pb, color_parameter_type, 4);

    if (strncmp(color_parameter_type, "nclx", 4) &&

        strncmp(color_parameter_type, "nclc", 4)) {

        av_log(c->fc, AV_LOG_WARNING, "unsupported color_parameter_type %s\n",

               color_parameter_type);

        return 0;

    }



    color_primaries = avio_rb16(pb);

    color_trc = avio_rb16(pb);

    color_matrix = avio_rb16(pb);



    av_log(c->fc, AV_LOG_TRACE,

           "%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",

           color_parameter_type, color_primaries, color_trc, color_matrix);



    if (!strncmp(color_parameter_type, "nclx", 4)) {

        uint8_t color_range = avio_r8(pb) >> 7;

        av_log(c->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);

        if (color_range)

            st->codec->color_range = AVCOL_RANGE_JPEG;

        else

            st->codec->color_range = AVCOL_RANGE_MPEG;

        



        if (color_primaries >= AVCOL_PRI_FILM)

            color_primaries = AVCOL_PRI_UNSPECIFIED;

        if ((color_trc >= AVCOL_TRC_LINEAR &&

             color_trc <= AVCOL_TRC_LOG_SQRT) ||

            color_trc >= AVCOL_TRC_BT2020_10)

            color_trc = AVCOL_TRC_UNSPECIFIED;

        if (color_matrix >= AVCOL_SPC_BT2020_NCL)

            color_matrix = AVCOL_SPC_UNSPECIFIED;

        st->codec->color_primaries = color_primaries;

        st->codec->color_trc = color_trc;

        st->codec->colorspace = color_matrix;

    } else if (!strncmp(color_parameter_type, "nclc", 4)) {

        

        switch (color_primaries) {

        case 1: st->codec->color_primaries = AVCOL_PRI_BT709; break;

        case 5: st->codec->color_primaries = AVCOL_PRI_SMPTE170M; break;

        case 6: st->codec->color_primaries = AVCOL_PRI_SMPTE240M; break;

        }

        

        switch (color_trc) {

        case 1: st->codec->color_trc = AVCOL_TRC_BT709; break;

        case 7: st->codec->color_trc = AVCOL_TRC_SMPTE240M; break;

        }

        

        switch (color_matrix) {

        case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;

        case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;

        case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;

        }

    }

    av_log(c->fc, AV_LOG_TRACE, "\n");



    return 0;

}

    avio_read(pb, color_parameter_type, 4);
static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)

{

    AVStream *st;

    char VAR_3[5] = { 0 };

    int VAR_4, VAR_5, VAR_6;



    if (VAR_0->fc->nb_streams < 1)

        return 0;

    st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1];



    avio_read(VAR_1, VAR_3, 4);

    if (strncmp(VAR_3, "nclx", 4) &&

        strncmp(VAR_3, "nclc", 4)) {

        av_log(VAR_0->fc, AV_LOG_WARNING, "unsupported VAR_3 %s\n",

               VAR_3);

        return 0;

    }



    VAR_4 = avio_rb16(VAR_1);

    VAR_5 = avio_rb16(VAR_1);

    VAR_6 = avio_rb16(VAR_1);



    av_log(VAR_0->fc, AV_LOG_TRACE,

           "%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",

           VAR_3, VAR_4, VAR_5, VAR_6);



    if (!strncmp(VAR_3, "nclx", 4)) {

        uint8_t color_range = avio_r8(VAR_1) >> 7;

        av_log(VAR_0->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range);

        if (color_range)

            st->codec->color_range = AVCOL_RANGE_JPEG;

        else

            st->codec->color_range = AVCOL_RANGE_MPEG;

        



        if (VAR_4 >= AVCOL_PRI_FILM)

            VAR_4 = AVCOL_PRI_UNSPECIFIED;

        if ((VAR_5 >= AVCOL_TRC_LINEAR &&

             VAR_5 <= AVCOL_TRC_LOG_SQRT) ||

            VAR_5 >= AVCOL_TRC_BT2020_10)

            VAR_5 = AVCOL_TRC_UNSPECIFIED;

        if (VAR_6 >= AVCOL_SPC_BT2020_NCL)

            VAR_6 = AVCOL_SPC_UNSPECIFIED;

        st->codec->VAR_4 = VAR_4;

        st->codec->VAR_5 = VAR_5;

        st->codec->colorspace = VAR_6;

    } else if (!strncmp(VAR_3, "nclc", 4)) {

        

        switch (VAR_4) {

        case 1: st->codec->VAR_4 = AVCOL_PRI_BT709; break;

        case 5: st->codec->VAR_4 = AVCOL_PRI_SMPTE170M; break;

        case 6: st->codec->VAR_4 = AVCOL_PRI_SMPTE240M; break;

        }

        

        switch (VAR_5) {

        case 1: st->codec->VAR_5 = AVCOL_TRC_BT709; break;

        case 7: st->codec->VAR_5 = AVCOL_TRC_SMPTE240M; break;

        }

        

        switch (VAR_6) {

        case 1: st->codec->colorspace = AVCOL_SPC_BT709; break;

        case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break;

        case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break;

        }

    }

    av_log(VAR_0->fc, AV_LOG_TRACE, "\n");



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ AVStream *st; char VAR_3[5] = { 0 }; int VAR_4, VAR_5, VAR_6; if (VAR_0->fc->nb_streams < 1)
return 0; st = VAR_0->fc->streams[VAR_0->fc->nb_streams - 1]; avio_read(VAR_1, VAR_3, 4); if (strncmp(VAR_3, "nclx", 4) &&
strncmp(VAR_3, "nclc", 4)) { av_log(VAR_0->fc, AV_LOG_WARNING, "unsupported VAR_3 %s\n",
VAR_3); return 0; } VAR_4 = avio_rb16(VAR_1); VAR_5 = avio_rb16(VAR_1); VAR_6 = avio_rb16(VAR_1); av_log(VAR_0->fc, AV_LOG_TRACE,
"%s: pri %"PRIu16" trc %"PRIu16" matrix %"PRIu16"",
VAR_3, VAR_4, VAR_5, VAR_6); if (!strncmp(VAR_3, "nclx", 4)) { uint8_t color_range = avio_r8(VAR_1) >> 7; av_log(VAR_0->fc, AV_LOG_TRACE, " full %"PRIu8"", color_range); if (color_range)
st->codec->color_range = AVCOL_RANGE_JPEG; else
st->codec->color_range = AVCOL_RANGE_MPEG; if (VAR_4 >= AVCOL_PRI_FILM)
VAR_4 = AVCOL_PRI_UNSPECIFIED; if ((VAR_5 >= AVCOL_TRC_LINEAR &&
VAR_5 <= AVCOL_TRC_LOG_SQRT) ||
VAR_5 >= AVCOL_TRC_BT2020_10)
VAR_5 = AVCOL_TRC_UNSPECIFIED; if (VAR_6 >= AVCOL_SPC_BT2020_NCL)
VAR_6 = AVCOL_SPC_UNSPECIFIED; st->codec->VAR_4 = VAR_4; st->codec->VAR_5 = VAR_5; st->codec->colorspace = VAR_6; } else if (!strncmp(VAR_3, "nclc", 4)) { switch (VAR_4) { case 1: st->codec->VAR_4 = AVCOL_PRI_BT709; break; case 5: st->codec->VAR_4 = AVCOL_PRI_SMPTE170M; break; case 6: st->codec->VAR_4 = AVCOL_PRI_SMPTE240M; break; } switch (VAR_5) { case 1: st->codec->VAR_5 = AVCOL_TRC_BT709; break; case 7: st->codec->VAR_5 = AVCOL_TRC_SMPTE240M; break; } switch (VAR_6) { case 1: st->codec->colorspace = AVCOL_SPC_BT709; break; case 6: st->codec->colorspace = AVCOL_SPC_BT470BG; break; case 7: st->codec->colorspace = AVCOL_SPC_SMPTE240M; break; } } av_log(VAR_0->fc, AV_LOG_TRACE, "\n"); return 0; }