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

{

    MOVStreamContext *sc;

    int i, edit_count, version;



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

        return 0;

    sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;



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

    avio_rb24(pb); /* flags */

    edit_count = avio_rb32(pb); /* entries */



    if (!edit_count)

        return 0;

    if (sc->elst_data)

        av_log(c->fc, AV_LOG_WARNING, "Duplicated ELST atom\n");

    av_free(sc->elst_data);

    sc->elst_count = 0;

    sc->elst_data = av_malloc_array(edit_count, sizeof(*sc->elst_data));

    if (!sc->elst_data)

        return AVERROR(ENOMEM);



    av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);

    for (i = 0; i < edit_count && !pb->eof_reached; i++) {

        MOVElst *e = &sc->elst_data[i];



        if (version == 1) {

            e->duration = avio_rb64(pb);

            e->time     = avio_rb64(pb);

        } else {

            e->duration = avio_rb32(pb); /* segment duration */

            e->time     = (int32_t)avio_rb32(pb); /* media time */

        }

        e->rate = avio_rb32(pb) / 65536.0;

        av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",

               e->duration, e->time, e->rate);



        if (e->time < 0 && e->time != -1 &&

            c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {

            av_log(c->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",

                   c->fc->nb_streams-1, i, e->time);

            return AVERROR_INVALIDDATA;

        }

    }

    sc->elst_count = i;



    return 0;

}

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

{

    MOVStreamContext *sc;

    int i, edit_count, version;



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

        return 0;

    sc = c->fc->streams[c->fc->nb_streams-1]->priv_data;



    version = avio_r8(pb); 

    avio_rb24(pb); 

    edit_count = avio_rb32(pb); 



    if (!edit_count)

        return 0;

    if (sc->elst_data)

        av_log(c->fc, AV_LOG_WARNING, "Duplicated ELST atom\n");

    av_free(sc->elst_data);

    sc->elst_count = 0;

    sc->elst_data = av_malloc_array(edit_count, sizeof(*sc->elst_data));

    if (!sc->elst_data)

        return AVERROR(ENOMEM);



    av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count);

    for (i = 0; i < edit_count && !pb->eof_reached; i++) {

        MOVElst *e = &sc->elst_data[i];



        if (version == 1) {

            e->duration = avio_rb64(pb);

            e->time     = avio_rb64(pb);

        } else {

            e->duration = avio_rb32(pb); 

            e->time     = (int32_t)avio_rb32(pb); 

        }

        e->rate = avio_rb32(pb) / 65536.0;

        av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",

               e->duration, e->time, e->rate);



        if (e->time < 0 && e->time != -1 &&

            c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {

            av_log(c->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",

                   c->fc->nb_streams-1, i, e->time);

            return AVERROR_INVALIDDATA;

        }

    }

    sc->elst_count = i;



    return 0;

}

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

{

    MOVStreamContext *sc;

    int VAR_3, VAR_4, VAR_5;



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

        return 0;

    sc = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]->priv_data;



    VAR_5 = avio_r8(VAR_1); 

    avio_rb24(VAR_1); 

    VAR_4 = avio_rb32(VAR_1); 



    if (!VAR_4)

        return 0;

    if (sc->elst_data)

        av_log(VAR_0->fc, AV_LOG_WARNING, "Duplicated ELST VAR_2\n");

    av_free(sc->elst_data);

    sc->elst_count = 0;

    sc->elst_data = av_malloc_array(VAR_4, sizeof(*sc->elst_data));

    if (!sc->elst_data)

        return AVERROR(ENOMEM);



    av_log(VAR_0->fc, AV_LOG_TRACE, "track[%u].VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams - 1, VAR_4);

    for (VAR_3 = 0; VAR_3 < VAR_4 && !VAR_1->eof_reached; VAR_3++) {

        MOVElst *e = &sc->elst_data[VAR_3];



        if (VAR_5 == 1) {

            e->duration = avio_rb64(VAR_1);

            e->time     = avio_rb64(VAR_1);

        } else {

            e->duration = avio_rb32(VAR_1); 

            e->time     = (int32_t)avio_rb32(VAR_1); 

        }

        e->rate = avio_rb32(VAR_1) / 65536.0;

        av_log(VAR_0->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",

               e->duration, e->time, e->rate);



        if (e->time < 0 && e->time != -1 &&

            VAR_0->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) {

            av_log(VAR_0->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",

                   VAR_0->fc->nb_streams-1, VAR_3, e->time);

            return AVERROR_INVALIDDATA;

        }

    }

    sc->elst_count = VAR_3;



    return 0;

}

static int FUNC_0(MOVContext *VAR_0, AVIOContext *VAR_1, MOVAtom VAR_2)
{ MOVStreamContext *sc; int VAR_3, VAR_4, VAR_5; if (VAR_0->fc->nb_streams < 1 || VAR_0->ignore_editlist)
return 0; sc = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]->priv_data; VAR_5 = avio_r8(VAR_1); avio_rb24(VAR_1); VAR_4 = avio_rb32(VAR_1); if (!VAR_4)
return 0; if (sc->elst_data)
av_log(VAR_0->fc, AV_LOG_WARNING, "Duplicated ELST VAR_2\n"); av_free(sc->elst_data); sc->elst_count = 0; sc->elst_data = av_malloc_array(VAR_4, sizeof(*sc->elst_data)); if (!sc->elst_data)
return AVERROR(ENOMEM); av_log(VAR_0->fc, AV_LOG_TRACE, "track[%u].VAR_4 = %VAR_3\n", VAR_0->fc->nb_streams - 1, VAR_4); for (VAR_3 = 0; VAR_3 < VAR_4 && !VAR_1->eof_reached; VAR_3++) { MOVElst *e = &sc->elst_data[VAR_3]; if (VAR_5 == 1) { e->duration = avio_rb64(VAR_1); e->time     = avio_rb64(VAR_1); } else { e->duration = avio_rb32(VAR_1); e->time     = (int32_t)avio_rb32(VAR_1); } e->rate = avio_rb32(VAR_1) / 65536.0; av_log(VAR_0->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n",
e->duration, e->time, e->rate); if (e->time < 0 && e->time != -1 &&
VAR_0->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) { av_log(VAR_0->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n",
VAR_0->fc->nb_streams-1, VAR_3, e->time); return AVERROR_INVALIDDATA; } } sc->elst_count = VAR_3; return 0; }