]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
set stream time_base properly
authormru <mru@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Fri, 12 May 2006 00:50:43 +0000 (00:50 +0000)
committermru <mru@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Fri, 12 May 2006 00:50:43 +0000 (00:50 +0000)
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@5367 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavformat/ogg2.c
libavformat/oggparseflac.c
libavformat/oggparseogm.c
libavformat/oggparsetheora.c
libavformat/oggparsevorbis.c

index 7daf5606414240409b26a06961ae8634d511054e..71b4d69a976afc23f00b880d24cb1ca59fb15fc5 100644 (file)
@@ -432,15 +432,11 @@ ogg_gptopts (AVFormatContext * s, int i, uint64_t gp)
 {
     ogg_t *ogg = s->priv_data;
     ogg_stream_t *os = ogg->streams + i;
-    AVStream *st = s->streams[i];
-    AVCodecContext *codec = st->codec;
     uint64_t pts = AV_NOPTS_VALUE;
 
     if(os->codec->gptopts){
         pts = os->codec->gptopts(s, i, gp);
-    } else if (codec->codec_type == CODEC_TYPE_AUDIO){
-        pts = gp * 1000000LL / codec->sample_rate;
-    }else if (codec->codec_type == CODEC_TYPE_VIDEO){
+    } else {
         pts = gp;
     }
 
index d1d53b0256473e9ef13d4f3138550ede2f0494fa..a63e9d2e60b3cce056fbead19dd57b147e8cfcd0 100644 (file)
@@ -63,6 +63,9 @@ flac_header (AVFormatContext * s, int idx)
         memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
                 FLAC_STREAMINFO_SIZE);
         st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
+
+        st->time_base.num = 1;
+        st->time_base.den = st->codec->sample_rate;
     } else if (mdt == 4) {
         vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
     }
index 6468bdf26023f6e9494e3c2ebc0819be7a0258b8..0e25dcc1ebc01015037085ec994dfbad43383078 100644 (file)
@@ -48,9 +48,12 @@ ogm_header(AVFormatContext *s, int idx)
     p++;
 
     if(*p == 'v'){
+        int tag;
         st->codec->codec_type = CODEC_TYPE_VIDEO;
         p += 8;
-        st->codec->codec_id = codec_get_bmp_id(le2me_32(unaligned32(p)));
+        tag = le2me_32(unaligned32(p));
+        st->codec->codec_id = codec_get_bmp_id(tag);
+        st->codec->codec_tag = tag;
     } else {
         int cid;
         st->codec->codec_type = CODEC_TYPE_AUDIO;
@@ -85,6 +88,8 @@ ogm_header(AVFormatContext *s, int idx)
         p += 2;                 /* block_align */
         st->codec->bit_rate = le2me_32(unaligned32(p)) * 8;
         st->codec->sample_rate = spu * 10000000 / time_unit;
+        st->time_base.num = 1;
+        st->time_base.den = st->codec->sample_rate;
     }
 
     return 1;
index 2f35d1b73c81462bd5dd4cfb879f3e8206201117..fcd9dc132c01b74e59835e673c13f55ec42144f0 100644 (file)
@@ -79,6 +79,7 @@ theora_header (AVFormatContext * s, int idx)
             skip_bits(&gb, 64);
         st->codec->time_base.den = get_bits(&gb, 32);
         st->codec->time_base.num = get_bits(&gb, 32);
+        st->time_base = st->codec->time_base;
 
         st->codec->sample_aspect_ratio.num = get_bits(&gb, 24);
         st->codec->sample_aspect_ratio.den = get_bits(&gb, 24);
@@ -111,15 +112,13 @@ theora_header (AVFormatContext * s, int idx)
 static uint64_t
 theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp)
 {
-    AVStream *st = ctx->streams[idx];
     ogg_t *ogg = ctx->priv_data;
     ogg_stream_t *os = ogg->streams + idx;
     theora_params_t *thp = os->private;
     uint64_t iframe = gp >> thp->gpshift;
     uint64_t pframe = gp & thp->gpmask;
 
-    return (iframe + pframe) * AV_TIME_BASE * st->codec->time_base.num /
-        st->codec->time_base.den;
+    return iframe + pframe;
 }
 
 ogg_codec_t theora_codec = {
index 202601fa9ed6b24afa99b82bcf3e52029e731be4..9eddeff09c3e8dd1a72f0f86e49c2b51249cb2bc 100644 (file)
@@ -186,6 +186,8 @@ vorbis_header (AVFormatContext * s, int idx)
         st->codec->codec_type = CODEC_TYPE_AUDIO;
         st->codec->codec_id = CODEC_ID_VORBIS;
 
+        st->time_base.num = 1;
+        st->time_base.den = st->codec->sample_rate;
     } else if (os->buf[os->pstart] == 3) {
         vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
     } else {