# HG changeset patch # User bcoudurier # Date 1244697203 0 # Node ID 7b260f4d453d788054559be1c59a532c0357d232 # Parent 54fa3d7ab724004d8e0f6f832517f7c57f22618d Remove time_rate, we cannot compute exactly when fragments are used and we cannot determine if fragments are present or not in streamed mode. diff -r 54fa3d7ab724 -r 7b260f4d453d isom.h --- a/isom.h Thu Jun 11 04:30:05 2009 +0000 +++ b/isom.h Thu Jun 11 05:13:23 2009 +0000 @@ -106,7 +106,6 @@ unsigned int keyframe_count; int *keyframes; int time_scale; - int time_rate; int time_offset; ///< time offset of the first edit list entry int current_sample; unsigned int bytes_per_frame; diff -r 54fa3d7ab724 -r 7b260f4d453d mov.c --- a/mov.c Thu Jun 11 04:30:05 2009 +0000 +++ b/mov.c Thu Jun 11 05:13:23 2009 +0000 @@ -1253,8 +1253,6 @@ sc->stts_data[i].count= sample_count; sc->stts_data[i].duration= sample_duration; - sc->time_rate= av_gcd(sc->time_rate, sample_duration); - dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration); duration+=(int64_t)sample_duration*sample_count; @@ -1282,8 +1280,6 @@ sc->dts_shift = get_be32(pb); dprintf(c->fc, "dts shift %d\n", sc->dts_shift); - sc->time_rate= av_gcd(sc->time_rate, FFABS(sc->dts_shift)); - get_be32(pb); // least dts to pts delta get_be32(pb); // greatest dts to pts delta get_be32(pb); // pts start @@ -1317,8 +1313,6 @@ sc->ctts_data[i].count = count; sc->ctts_data[i].duration= duration; - - sc->time_rate= av_gcd(sc->time_rate, FFABS(duration)); } return 0; } @@ -1337,8 +1331,7 @@ /* adjust first dts according to edit list */ if (sc->time_offset) { int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset; - assert(sc->time_offset % sc->time_rate == 0); - current_dts = - (rescaled / sc->time_rate); + current_dts = -rescaled; if (sc->ctts_data && sc->ctts_data[0].duration / sc->stts_data[0].duration > 16) { /* more than 16 frames delay, dts are likely wrong this happens with files created by iMovie */ @@ -1356,7 +1349,6 @@ unsigned int distance = 0; int key_off = sc->keyframes && sc->keyframes[0] == 1; - sc->dts_shift /= sc->time_rate; current_dts -= sc->dts_shift; st->nb_frames = sc->sample_count; @@ -1394,8 +1386,7 @@ } current_offset += sample_size; - assert(sc->stts_data[stts_index].duration % sc->time_rate == 0); - current_dts += sc->stts_data[stts_index].duration / sc->time_rate; + current_dts += sc->stts_data[stts_index].duration; distance++; stts_sample++; current_sample++; @@ -1443,8 +1434,7 @@ size, samples); current_offset += size; - assert(samples % sc->time_rate == 0); - current_dts += samples / sc->time_rate; + current_dts += samples; chunk_samples -= samples; } } @@ -1477,12 +1467,10 @@ return 0; } - if (!sc->time_rate) - sc->time_rate = 1; if (!sc->time_scale) sc->time_scale = c->time_scale; - av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); + av_set_pts_info(st, 64, 1, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { @@ -1491,11 +1479,6 @@ dprintf(c->fc, "frame size %d\n", st->codec->frame_size); } - if (st->duration != AV_NOPTS_VALUE) { - assert(st->duration % sc->time_rate == 0); - st->duration /= sc->time_rate; - } - mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { @@ -1754,8 +1737,7 @@ "size %d, distance %d, keyframe %d\n", st->index, sc->sample_count+i, offset, dts, sample_size, distance, keyframe); distance++; - assert(sample_duration % sc->time_rate == 0); - dts += sample_duration / sc->time_rate; + dts += sample_duration; offset += sample_size; } frag->moof_offset = offset; @@ -1856,7 +1838,6 @@ get_be32(pb); /* Media rate */ if (i == 0 && time >= -1) { sc->time_offset = time != -1 ? time : -duration; - sc->time_rate = av_gcd(sc->time_rate, FFABS(sc->time_offset)); } } @@ -2006,8 +1987,7 @@ MOVStreamContext *msc = st->priv_data; if (st->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < st->nb_index_entries) { AVIndexEntry *current_sample = &st->index_entries[msc->current_sample]; - int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, - AV_TIME_BASE, msc->time_scale); + int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale); dprintf(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) || (!url_is_streamed(s->pb) && @@ -2051,8 +2031,7 @@ pkt->stream_index = sc->ffindex; pkt->dts = sample->timestamp; if (sc->ctts_data) { - assert(sc->ctts_data[sc->ctts_index].duration % sc->time_rate == 0); - pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration / sc->time_rate; + pkt->pts = pkt->dts + sc->dts_shift + sc->ctts_data[sc->ctts_index].duration; /* update ctts context */ sc->ctts_sample++; if (sc->ctts_index < sc->ctts_count &&