[Ffmpeg-cvslog] CVS: ffmpeg/libavformat mov.c,1.85,1.86
Michael Niedermayer CVS
michael
Fri Jun 24 13:43:10 CEST 2005
Update of /cvsroot/ffmpeg/ffmpeg/libavformat
In directory mail:/var2/tmp/cvs-serv4019
Modified Files:
mov.c
Log Message:
another chapter in the neverending mov demuxer cleanup
a timebase isnt an average frame rate neither can highlevel (considering edit lists) duration be mixed with lowlevel ones
Index: mov.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavformat/mov.c,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -d -r1.85 -r1.86
--- mov.c 26 May 2005 20:17:11 -0000 1.85
+++ mov.c 24 Jun 2005 11:43:08 -0000 1.86
@@ -652,7 +652,7 @@
#ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "track[%i].time_scale = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->time_scale); /* time scale */
#endif
- get_be32(pb); /* duration */
+ c->fc->streams[c->fc->nb_streams-1]->duration= get_be32(pb); /* duration */
get_be16(pb); /* language */
get_be16(pb); /* quality */
@@ -1338,44 +1338,20 @@
sample_duration = get_be32(pb);
c->streams[c->fc->nb_streams - 1]->stts_data[i].count= sample_count;
c->streams[c->fc->nb_streams - 1]->stts_data[i].duration= sample_duration;
+
#ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration);
#endif
duration+=sample_duration*sample_count;
total_sample_count+=sample_count;
-
-#if 0 //We calculate an average instead, needed by .mp4-files created with nec e606 3g phone
-
- if (!i && st->codec.codec_type==CODEC_TYPE_VIDEO) {
- st->codec.time_base.num = sample_duration ? sample_duration : 1;
- st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale;
-#ifdef DEBUG
- av_log(NULL, AV_LOG_DEBUG, "VIDEO FRAME RATE= %i (sd= %i)\n", st->codec.time_base.den, sample_duration);
-#endif
- }
-#endif
}
- /*The stsd atom which contain codec type sometimes comes after the stts so we cannot check for codec_type*/
- if(duration>0)
- {
- av_reduce(
- &st->codec.time_base.den,
- &st->codec.time_base.num,
- c->streams[c->fc->nb_streams-1]->time_scale * total_sample_count,
- duration,
- INT_MAX
- );
-
-#ifdef DEBUG
- av_log(NULL, AV_LOG_DEBUG, "FRAME RATE average (video or audio)= %f (tot sample count= %i ,tot dur= %i timescale=%d)\n", (float)st->codec.time_base.den/st->codec.time_base.num,total_sample_count,duration,c->streams[c->fc->nb_streams-1]->time_scale);
-#endif
- }
- else
- {
- st->codec.time_base.num = 1;
- st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale;
- }
+ av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale);
+// st->codec.time_base.num = 1;
+// st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale;
+ st->nb_frames= total_sample_count;
+ if(duration)
+ st->duration= duration;
return 0;
}
@@ -1425,7 +1401,6 @@
st->priv_data = sc;
st->codec.codec_type = CODEC_TYPE_MOV_OTHER;
st->start_time = 0; /* XXX: check */
- st->duration = (c->duration * (int64_t)AV_TIME_BASE) / c->time_scale;
c->streams[c->fc->nb_streams-1] = sc;
return mov_read_default(c, pb, atom);
@@ -1455,7 +1430,7 @@
st->id = (int)get_be32(pb); /* track id (NOT 0 !)*/
get_be32(pb); /* reserved */
st->start_time = 0; /* check */
- st->duration = (get_be32(pb) * (int64_t)AV_TIME_BASE) / c->time_scale; /* duration */
+ get_be32(pb); /* highlevel (considering edits) duration in movie timebase */
get_be32(pb); /* reserved */
get_be32(pb); /* reserved */
@@ -2033,12 +2008,8 @@
pts = dts + duration;
}else
pts = dts;
- pkt->pts = av_rescale( pts,
- (int64_t)s->streams[sc->ffindex]->time_base.den,
- (int64_t)sc->time_scale * (int64_t)s->streams[sc->ffindex]->time_base.num );
- pkt->dts = av_rescale( dts,
- (int64_t)s->streams[sc->ffindex]->time_base.den,
- (int64_t)sc->time_scale * (int64_t)s->streams[sc->ffindex]->time_base.num );
+ pkt->pts = pts;
+ pkt->dts = dts;
#ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "stream #%d smp #%ld dts = %lld pts = %lld (smp:%ld time:%lld idx:%d ent:%d count:%d dur:%d)\n"
, pkt->stream_index, sc->current_sample-1, pkt->dts, pkt->pts
@@ -2058,12 +2029,11 @@
/**
* Seek method based on the one described in the Appendix C of QTFileFormat.pdf
*/
-static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
+static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
{
MOVContext* mov = (MOVContext *) s->priv_data;
MOVStreamContext* sc;
int32_t i, a, b, m;
- int64_t sample_time;
int64_t start_time;
int32_t seek_sample, sample;
int32_t duration;
@@ -2100,10 +2070,6 @@
#ifdef DEBUG
av_log(s, AV_LOG_DEBUG, "Searching for time %li in stream #%i (time_scale=%i)\n", (long)timestamp, mov_idx, sc->time_scale);
#endif
- // convert timestamp from time_base unit to timescale unit
- sample_time = av_rescale( timestamp,
- (int64_t)sc->time_scale * s->streams[stream_index]->time_base.num,
- (int64_t)s->streams[stream_index]->time_base.den);
start_time = 0; // FIXME use elst atom
sample = 1; // sample are 0 based in table
#ifdef DEBUG
More information about the ffmpeg-cvslog
mailing list