Browse code

Always use av_set_pts_info to set the stream time base.

Reimar Döffinger authored on 2011/02/01 04:08:56
Showing 8 changed files
... ...
@@ -89,7 +89,7 @@ static int read_header(AVFormatContext *s,
89 89
     video->codec->height = 192;
90 90
     /* 4:3 320x200 with 8 empty lines */
91 91
     video->sample_aspect_ratio = (AVRational) { 5, 6 };
92
-    video->time_base = (AVRational) { 2, 25 };
92
+    av_set_pts_info(video, 64, 2, 25);
93 93
     video->nb_frames = framecount;
94 94
     video->duration = framecount;
95 95
     video->start_time = 0;
... ...
@@ -42,7 +42,7 @@ static int dirac_header(AVFormatContext *s, int idx)
42 42
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
43 43
     st->codec->codec_id = CODEC_ID_DIRAC;
44 44
     // dirac in ogg always stores timestamps as though the video were interlaced
45
-    st->time_base = (AVRational){st->codec->time_base.num, 2*st->codec->time_base.den};
45
+    av_set_pts_info(st, 64, st->codec->time_base.num, 2*st->codec->time_base.den);
46 46
     return 1;
47 47
 }
48 48
 
... ...
@@ -79,8 +79,7 @@ static int old_dirac_header(AVFormatContext *s, int idx)
79 79
 
80 80
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
81 81
     st->codec->codec_id = CODEC_ID_DIRAC;
82
-    st->time_base.den = AV_RB32(buf+8);
83
-    st->time_base.num = AV_RB32(buf+12);
82
+    av_set_pts_info(st, 64, AV_RB32(buf+12), AV_RB32(buf+8));
84 83
     return 1;
85 84
 }
86 85
 
... ...
@@ -65,8 +65,7 @@ flac_header (AVFormatContext * s, int idx)
65 65
         memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
66 66
         st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
67 67
 
68
-        st->time_base.num = 1;
69
-        st->time_base.den = st->codec->sample_rate;
68
+        av_set_pts_info(st, 64, 1, st->codec->sample_rate);
70 69
     } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
71 70
         ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4);
72 71
     }
... ...
@@ -83,14 +83,13 @@ ogm_header(AVFormatContext *s, int idx)
83 83
             st->codec->height = bytestream_get_le32(&p);
84 84
             st->codec->time_base.den = spu * 10000000;
85 85
             st->codec->time_base.num = time_unit;
86
-            st->time_base = st->codec->time_base;
86
+            av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
87 87
         } else {
88 88
             st->codec->channels = bytestream_get_le16(&p);
89 89
             p += 2;                 /* block_align */
90 90
             st->codec->bit_rate = bytestream_get_le32(&p) * 8;
91 91
             st->codec->sample_rate = spu * 10000000 / time_unit;
92
-            st->time_base.num = 1;
93
-            st->time_base.den = st->codec->sample_rate;
92
+            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
94 93
         }
95 94
     } else if (*p == 3) {
96 95
         if (os->psize > 8)
... ...
@@ -60,8 +60,9 @@ static int skeleton_header(AVFormatContext *s, int idx)
60 60
         start_den = AV_RL64(buf+20);
61 61
 
62 62
         if (start_den) {
63
-            av_reduce(&start_time, &st->time_base.den, start_num, start_den, INT_MAX);
64
-            st->time_base.num = 1;
63
+            int64_t base_den;
64
+            av_reduce(&start_time, &base_den, start_num, start_den, INT_MAX);
65
+            av_set_pts_info(st, 64, 1, base_den);
65 66
             os->lastpts =
66 67
             st->start_time = start_time;
67 68
         }
... ...
@@ -72,8 +72,7 @@ static int speex_header(AVFormatContext *s, int idx) {
72 72
                                          + FF_INPUT_BUFFER_PADDING_SIZE);
73 73
         memcpy(st->codec->extradata, p, st->codec->extradata_size);
74 74
 
75
-        st->time_base.num = 1;
76
-        st->time_base.den = st->codec->sample_rate;
75
+        av_set_pts_info(st, 64, 1, st->codec->sample_rate);
77 76
     } else
78 77
         ff_vorbis_comment(s, &st->metadata, p, os->psize);
79 78
 
... ...
@@ -91,7 +91,7 @@ theora_header (AVFormatContext * s, int idx)
91 91
             st->codec->time_base.num = 1;
92 92
             st->codec->time_base.den = 25;
93 93
         }
94
-        st->time_base = st->codec->time_base;
94
+        av_set_pts_info(st, 64, st->codec->time_base.num, st->codec->time_base.den);
95 95
 
96 96
         st->sample_aspect_ratio.num = get_bits_long(&gb, 24);
97 97
         st->sample_aspect_ratio.den = get_bits_long(&gb, 24);
... ...
@@ -252,8 +252,7 @@ vorbis_header (AVFormatContext * s, int idx)
252 252
 
253 253
         if (srate > 0) {
254 254
             st->codec->sample_rate = srate;
255
-            st->time_base.num = 1;
256
-            st->time_base.den = srate;
255
+            av_set_pts_info(st, 64, 1, srate);
257 256
         }
258 257
     } else if (os->buf[os->pstart] == 3) {
259 258
         if (os->psize > 8 &&