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

{

    int i;

    int64_t creation_time;

    int version = avio_r8(pb); /* version */

    avio_rb24(pb); /* flags */



    if (version == 1) {

        creation_time = avio_rb64(pb);

        avio_rb64(pb);

    } else {

        creation_time = avio_rb32(pb);

        avio_rb32(pb); /* modification time */

    }

    mov_metadata_creation_time(&c->fc->metadata, creation_time);

    c->time_scale = avio_rb32(pb); /* time scale */

    if (c->time_scale <= 0) {

        av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", c->time_scale);

        return AVERROR_INVALIDDATA;

    }

    av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);



    c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */

    // set the AVCodecContext duration because the duration of individual tracks

    // may be inaccurate

    if (c->time_scale > 0 && !c->trex_data)

        c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);

    avio_rb32(pb); /* preferred scale */



    avio_rb16(pb); /* preferred volume */



    avio_skip(pb, 10); /* reserved */



    /* movie display matrix, store it in main context and use it later on */

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

        c->movie_display_matrix[i][0] = avio_rb32(pb); // 16.16 fixed point

        c->movie_display_matrix[i][1] = avio_rb32(pb); // 16.16 fixed point

        c->movie_display_matrix[i][2] = avio_rb32(pb); //  2.30 fixed point

    }



    avio_rb32(pb); /* preview time */

    avio_rb32(pb); /* preview duration */

    avio_rb32(pb); /* poster time */

    avio_rb32(pb); /* selection time */

    avio_rb32(pb); /* selection duration */

    avio_rb32(pb); /* current time */

    avio_rb32(pb); /* next track ID */



    return 0;

}

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

{

    int i;

    int64_t creation_time;

    int version = avio_r8(pb); 

    avio_rb24(pb); 



    if (version == 1) {

        creation_time = avio_rb64(pb);

        avio_rb64(pb);

    } else {

        creation_time = avio_rb32(pb);

        avio_rb32(pb); 

    }

    mov_metadata_creation_time(&c->fc->metadata, creation_time);

    c->time_scale = avio_rb32(pb); 

    if (c->time_scale <= 0) {

        av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", c->time_scale);

        return AVERROR_INVALIDDATA;

    }

    av_log(c->fc, AV_LOG_TRACE, "time scale = %i\n", c->time_scale);



    c->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); 

    

    

    if (c->time_scale > 0 && !c->trex_data)

        c->fc->duration = av_rescale(c->duration, AV_TIME_BASE, c->time_scale);

    avio_rb32(pb); 



    avio_rb16(pb); 



    avio_skip(pb, 10); 



    

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

        c->movie_display_matrix[i][0] = avio_rb32(pb); 

        c->movie_display_matrix[i][1] = avio_rb32(pb); 

        c->movie_display_matrix[i][2] = avio_rb32(pb); 

    }



    avio_rb32(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 

    avio_rb32(pb); 



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)

{

    int VAR_3;

    int64_t creation_time;

    int VAR_4 = avio_r8(VAR_1); 

    avio_rb24(VAR_1); 



    if (VAR_4 == 1) {

        creation_time = avio_rb64(VAR_1);

        avio_rb64(VAR_1);

    } else {

        creation_time = avio_rb32(VAR_1);

        avio_rb32(VAR_1); 

    }

    mov_metadata_creation_time(&VAR_0->fc->metadata, creation_time);

    VAR_0->time_scale = avio_rb32(VAR_1); 

    if (VAR_0->time_scale <= 0) {

        av_log(VAR_0->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", VAR_0->time_scale);

        return AVERROR_INVALIDDATA;

    }

    av_log(VAR_0->fc, AV_LOG_TRACE, "time scale = %VAR_3\n", VAR_0->time_scale);



    VAR_0->duration = (VAR_4 == 1) ? avio_rb64(VAR_1) : avio_rb32(VAR_1); 

    

    

    if (VAR_0->time_scale > 0 && !VAR_0->trex_data)

        VAR_0->fc->duration = av_rescale(VAR_0->duration, AV_TIME_BASE, VAR_0->time_scale);

    avio_rb32(VAR_1); 



    avio_rb16(VAR_1); 



    avio_skip(VAR_1, 10); 



    

    for (VAR_3 = 0; VAR_3 < 3; VAR_3++) {

        VAR_0->movie_display_matrix[VAR_3][0] = avio_rb32(VAR_1); 

        VAR_0->movie_display_matrix[VAR_3][1] = avio_rb32(VAR_1); 

        VAR_0->movie_display_matrix[VAR_3][2] = avio_rb32(VAR_1); 

    }



    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 

    avio_rb32(VAR_1); 



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ int VAR_3; int64_t creation_time; int VAR_4 = avio_r8(VAR_1); avio_rb24(VAR_1); if (VAR_4 == 1) { creation_time = avio_rb64(VAR_1); avio_rb64(VAR_1); } else { creation_time = avio_rb32(VAR_1); avio_rb32(VAR_1); } mov_metadata_creation_time(&VAR_0->fc->metadata, creation_time); VAR_0->time_scale = avio_rb32(VAR_1); if (VAR_0->time_scale <= 0) { av_log(VAR_0->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d\n", VAR_0->time_scale); return AVERROR_INVALIDDATA; } av_log(VAR_0->fc, AV_LOG_TRACE, "time scale = %VAR_3\n", VAR_0->time_scale); VAR_0->duration = (VAR_4 == 1) ? avio_rb64(VAR_1) : avio_rb32(VAR_1); if (VAR_0->time_scale > 0 && !VAR_0->trex_data)
VAR_0->fc->duration = av_rescale(VAR_0->duration, AV_TIME_BASE, VAR_0->time_scale); avio_rb32(VAR_1); avio_rb16(VAR_1); avio_skip(VAR_1, 10); for (VAR_3 = 0; VAR_3 < 3; VAR_3++) { VAR_0->movie_display_matrix[VAR_3][0] = avio_rb32(VAR_1); VAR_0->movie_display_matrix[VAR_3][1] = avio_rb32(VAR_1); VAR_0->movie_display_matrix[VAR_3][2] = avio_rb32(VAR_1); } avio_rb32(VAR_1); avio_rb32(VAR_1); avio_rb32(VAR_1); avio_rb32(VAR_1); avio_rb32(VAR_1); avio_rb32(VAR_1); avio_rb32(VAR_1); return 0; }