static int mov_seek_stream(AVStream *st, int64_t timestamp, int flags)

{

    MOVStreamContext *sc = st->priv_data;

    int sample, time_sample;

    int i;



    sample = av_index_search_timestamp(st, timestamp, flags);

    dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);

    if (sample < 0) /* not sure what to do */

        return -1;

    sc->current_sample = sample;

    dprintf(st->codec, "stream %d, found sample %d\n", st->index, sc->current_sample);

    /* adjust ctts index */

    if (sc->ctts_data) {

        time_sample = 0;

        for (i = 0; i < sc->ctts_count; i++) {

            time_sample += sc->ctts_data[i].count;

            if (time_sample >= sc->current_sample) {

                sc->sample_to_ctime_index = i;

                sc->sample_to_ctime_sample = time_sample - sc->current_sample;

                break;

            }

        }

    }

    return sample;

}

static int mov_seek_stream(AVStream *st, int64_t timestamp, int flags)

{

    MOVStreamContext *sc = st->priv_data;

    int sample, time_sample;

    int i;



    sample = av_index_search_timestamp(st, timestamp, flags);

    dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);

    if (sample < 0) 

        return -1;

    sc->current_sample = sample;

    dprintf(st->codec, "stream %d, found sample %d\n", st->index, sc->current_sample);

    

    if (sc->ctts_data) {

        time_sample = 0;

        for (i = 0; i < sc->ctts_count; i++) {

            time_sample += sc->ctts_data[i].count;

            if (time_sample >= sc->current_sample) {

                sc->sample_to_ctime_index = i;

                sc->sample_to_ctime_sample = time_sample - sc->current_sample;

                break;

            }

        }

    }

    return sample;

}

static int FUNC_0(AVStream *VAR_0, int64_t VAR_1, int VAR_2)

{

    MOVStreamContext *sc = VAR_0->priv_data;

    int VAR_3, VAR_4;

    int VAR_5;



    VAR_3 = av_index_search_timestamp(VAR_0, VAR_1, VAR_2);

    dprintf(VAR_0->codec, "stream %d, VAR_1 %"PRId64", VAR_3 %d\n", VAR_0->index, VAR_1, VAR_3);

    if (VAR_3 < 0) 

        return -1;

    sc->current_sample = VAR_3;

    dprintf(VAR_0->codec, "stream %d, found VAR_3 %d\n", VAR_0->index, sc->current_sample);

    

    if (sc->ctts_data) {

        VAR_4 = 0;

        for (VAR_5 = 0; VAR_5 < sc->ctts_count; VAR_5++) {

            VAR_4 += sc->ctts_data[VAR_5].count;

            if (VAR_4 >= sc->current_sample) {

                sc->sample_to_ctime_index = VAR_5;

                sc->sample_to_ctime_sample = VAR_4 - sc->current_sample;

                break;

            }

        }

    }

    return VAR_3;

}

static int FUNC_0(AVStream *VAR_0, int64_t VAR_1, int VAR_2)
{ MOVStreamContext *sc = VAR_0->priv_data; int VAR_3, VAR_4; int VAR_5; VAR_3 = av_index_search_timestamp(VAR_0, VAR_1, VAR_2); dprintf(VAR_0->codec, "stream %d, VAR_1 %"PRId64", VAR_3 %d\n", VAR_0->index, VAR_1, VAR_3); if (VAR_3 < 0)
return -1; sc->current_sample = VAR_3; dprintf(VAR_0->codec, "stream %d, found VAR_3 %d\n", VAR_0->index, sc->current_sample); if (sc->ctts_data) { VAR_4 = 0; for (VAR_5 = 0; VAR_5 < sc->ctts_count; VAR_5++) { VAR_4 += sc->ctts_data[VAR_5].count; if (VAR_4 >= sc->current_sample) { sc->sample_to_ctime_index = VAR_5; sc->sample_to_ctime_sample = VAR_4 - sc->current_sample; break; } } } return VAR_3; }