Split ff_set_mpeg4_time() and move the non mpeg4 specific part
authorAurelien Jacobs <aurel@gnuage.org>
Tue, 10 Jul 2007 14:37:33 +0000 (14:37 +0000)
committerAurelien Jacobs <aurel@gnuage.org>
Tue, 10 Jul 2007 14:37:33 +0000 (14:37 +0000)
into mpegvideo_enc.c.

Originally committed as revision 9577 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/h263.c
libavcodec/mpegvideo.h
libavcodec/mpegvideo_enc.c

index 3e1b57a..cfb67b1 100644 (file)
@@ -2259,25 +2259,12 @@ void ff_mpeg4_stuffing(PutBitContext * pbc)
 }
 
 /* must be called before writing the header */
 }
 
 /* must be called before writing the header */
-void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
-    int time_div, time_mod;
-
-    assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
-    s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
-
-    time_div= s->time/s->avctx->time_base.den;
-    time_mod= s->time%s->avctx->time_base.den;
-
+void ff_set_mpeg4_time(MpegEncContext * s){
     if(s->pict_type==B_TYPE){
     if(s->pict_type==B_TYPE){
-        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
-        assert(s->pb_time > 0 && s->pb_time < s->pp_time);
         ff_mpeg4_init_direct_mv(s);
     }else{
         s->last_time_base= s->time_base;
         ff_mpeg4_init_direct_mv(s);
     }else{
         s->last_time_base= s->time_base;
-        s->time_base= time_div;
-        s->pp_time= s->time - s->last_non_b_time;
-        s->last_non_b_time= s->time;
-        assert(picture_number==0 || s->pp_time > 0);
+        s->time_base= s->time/s->avctx->time_base.den;
     }
 }
 
     }
 }
 
index d4a11aa..8e2cac5 100644 (file)
@@ -834,7 +834,7 @@ int16_t *h263_pred_motion(MpegEncContext * s, int block, int dir,
                         int *px, int *py);
 void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
                    int dir);
                         int *px, int *py);
 void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
                    int dir);
-void ff_set_mpeg4_time(MpegEncContext * s, int picture_number);
+void ff_set_mpeg4_time(MpegEncContext * s);
 void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
 #ifdef CONFIG_ENCODERS
 void h263_encode_init(MpegEncContext *s);
 void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
 #ifdef CONFIG_ENCODERS
 void h263_encode_init(MpegEncContext *s);
index 4f933a6..f7d6896 100644 (file)
@@ -2671,6 +2671,21 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
     return 0;
 }
 
     return 0;
 }
 
+/* must be called before writing the header */
+static void set_frame_distances(MpegEncContext * s){
+    assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
+    s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
+
+    if(s->pict_type==B_TYPE){
+        s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
+        assert(s->pb_time > 0 && s->pb_time < s->pp_time);
+    }else{
+        s->pp_time= s->time - s->last_non_b_time;
+        s->last_non_b_time= s->time;
+        assert(s->picture_number==0 || s->pp_time > 0);
+    }
+}
+
 static int encode_picture(MpegEncContext *s, int picture_number)
 {
     int i;
 static int encode_picture(MpegEncContext *s, int picture_number)
 {
     int i;
@@ -2685,7 +2700,9 @@ static int encode_picture(MpegEncContext *s, int picture_number)
     /* we need to initialize some time vars before we can encode b-frames */
     // RAL: Condition added for MPEG1VIDEO
     if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
     /* we need to initialize some time vars before we can encode b-frames */
     // RAL: Condition added for MPEG1VIDEO
     if (s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO || (s->h263_pred && !s->h263_msmpeg4))
-        ff_set_mpeg4_time(s, s->picture_number);  //FIXME rename and use has_b_frames or similar
+        set_frame_distances(s);
+    if(ENABLE_MPEG4_ENCODER && s->codec_id == CODEC_ID_MPEG4)
+        ff_set_mpeg4_time(s);
 
     s->me.scene_change_score=0;
 
 
     s->me.scene_change_score=0;