make StreamContext.time_base a pointer
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 9 Aug 2007 11:04:43 +0000 (11:04 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 9 Aug 2007 11:04:43 +0000 (11:04 +0000)
Originally committed as revision 10010 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/nut.h
libavformat/nutdec.c
libavformat/nutenc.c

index 2faf6958a133f2b5a796312c799d7199b59d6611..a5363d61dcd04eee2c09a78f6e2dd551e06d73e3 100644 (file)
@@ -72,7 +72,7 @@ typedef struct {
     int skip_until_key_frame;
     int64_t last_pts;
     int time_base_id;
-    AVRational time_base;
+    AVRational *time_base;
     int msb_pts_shift;
     int max_pts_distance;
     int decode_delay; //FIXME duplicate of has_b_frames
index 8eb727b257602a1ee2c0010b5b925ad9c565815c..60ae789ed844bdf42b4a20ce5b4c8fe1b8bd6def 100644 (file)
@@ -288,7 +288,7 @@ static int decode_stream_header(NUTContext *nut){
     end= get_packetheader(nut, bc, 1);
     end += url_ftell(bc);
 
-    GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base.num);
+    GET_V(stream_id, tmp < s->nb_streams && !nut->stream[tmp].time_base);
     stc= &nut->stream[stream_id];
 
     st = s->streams[stream_id];
@@ -358,8 +358,8 @@ static int decode_stream_header(NUTContext *nut){
         av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id);
         return -1;
     }
-    stc->time_base= nut->time_base[stc->time_base_id];
-    av_set_pts_info(s->streams[stream_id], 63, stc->time_base.num, stc->time_base.den);
+    stc->time_base= &nut->time_base[stc->time_base_id];
+    av_set_pts_info(s->streams[stream_id], 63, stc->time_base->num, stc->time_base->den);
     return 0;
 }
 
@@ -461,8 +461,8 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
     for(i=0; i<s->nb_streams; i++){
         nut->stream[i].last_pts= av_rescale_rnd(
             tmp / nut->time_base_count,
-            time_base.num * (int64_t)nut->stream[i].time_base.den,
-            time_base.den * (int64_t)nut->stream[i].time_base.num,
+            time_base.num * (int64_t)nut->stream[i].time_base->den,
+            time_base.den * (int64_t)nut->stream[i].time_base->num,
             AV_ROUND_DOWN);
         //last_key_frame ?
     }
index cda4704f6f05309473b4e5e5206bb948a252125b..5e7becaf685c191a887176b2adceed7d601aadd3 100644 (file)
@@ -236,29 +236,28 @@ static int write_header(AVFormatContext *s){
 
     for(i=0; i<s->nb_streams; i++){
         AVStream *st= s->streams[i];
-        int num, denom, ssize;
-        ff_parse_specific_params(st->codec, &num, &ssize, &denom);
+        int ssize;
+        AVRational time_base;
+        ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num);
 
-        nut->stream[i].time_base= (AVRational){denom, num};
-
-        av_set_pts_info(st, 64, denom, num);
+        av_set_pts_info(st, 64, time_base.num, time_base.den);
 
         for(j=0; j<nut->time_base_count; j++){
-            if(!memcmp(&nut->stream[i].time_base, &nut->time_base[j], sizeof(AVRational))){
+            if(!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))){
                 break;
             }
         }
-        nut->time_base[j]= nut->stream[i].time_base;
+        nut->time_base[j]= time_base;
+        nut->stream[i].time_base= &nut->time_base[j];
         if(j==nut->time_base_count)
             nut->time_base_count++;
 
-        if(av_q2d(nut->stream[i].time_base) >= 0.001)
+        if(av_q2d(time_base) >= 0.001)
             nut->stream[i].msb_pts_shift = 7;
         else
             nut->stream[i].msb_pts_shift = 14;
-        nut->stream[i].max_pts_distance= FFMAX(1/av_q2d(nut->stream[i].time_base), 1);
+        nut->stream[i].max_pts_distance= FFMAX(1/av_q2d(time_base), 1);
     }
-//FIXME make nut->stream[i].time_base pointers into nut->time_base
 
     put_buffer(bc, ID_STRING, strlen(ID_STRING));
     put_byte(bc, 0);