changeset 1705:954593137d37 libavcodec

picture number fixes
author michael
date Mon, 29 Dec 2003 22:25:08 +0000
parents 8bccf5eda14b
children 3ba5c493db6f
files mpegvideo.c mpegvideo.h ratecontrol.c
diffstat 3 files changed, 11 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Sun Dec 28 11:35:54 2003 +0000
+++ b/mpegvideo.c	Mon Dec 29 22:25:08 2003 +0000
@@ -427,6 +427,7 @@
     if (!s->encoding)
         s->progressive_sequence= 1;
     s->progressive_frame= 1;
+    s->coded_picture_number = 0;
 
     y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
     c_size = (s->mb_width + 2) * (s->mb_height + 2);
@@ -975,6 +976,7 @@
         return -1;
 
     s->picture_number = 0;
+    s->input_picture_number = 0;
     s->picture_in_gop_number = 0;
     s->fake_picture_number = 0;
     /* motion detector init */
@@ -1153,8 +1155,7 @@
 
         pic->reference= s->pict_type != B_TYPE ? 3 : 0;
 
-        if(s->current_picture_ptr) //FIXME broken, we need a coded_picture_number in MpegEncContext
-            pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
+        pic->coded_picture_number= s->coded_picture_number++;
         
         if( alloc_picture(s, (Picture*)pic, 0) < 0)
             return -1;
@@ -1644,9 +1645,7 @@
     }
     copy_picture_attributes(pic, pic_arg);
     
-    if(s->input_picture[encoding_delay])
-        pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1;
-    
+    pic->display_picture_number= s->input_picture_number++;
   }
 
     /* shift buffer entries */
@@ -1660,10 +1659,6 @@
 
 static void select_input_picture(MpegEncContext *s){
     int i;
-    int coded_pic_num=0;    
-
-    if(s->reordered_input_picture[0])
-        coded_pic_num= s->reordered_input_picture[0]->coded_picture_number + 1;
 
     for(i=1; i<MAX_PICTURE_COUNT; i++)
         s->reordered_input_picture[i-1]= s->reordered_input_picture[i];
@@ -1674,7 +1669,7 @@
         if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){
             s->reordered_input_picture[0]= s->input_picture[0];
             s->reordered_input_picture[0]->pict_type= I_TYPE;
-            s->reordered_input_picture[0]->coded_picture_number= coded_pic_num;
+            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
         }else{
             int b_frames;
             
@@ -1735,12 +1730,11 @@
                 s->reordered_input_picture[0]->pict_type= I_TYPE;
             else
                 s->reordered_input_picture[0]->pict_type= P_TYPE;
-            s->reordered_input_picture[0]->coded_picture_number= coded_pic_num;
+            s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++;
             for(i=0; i<b_frames; i++){
-                coded_pic_num++;
                 s->reordered_input_picture[i+1]= s->input_picture[i];
                 s->reordered_input_picture[i+1]->pict_type= B_TYPE;
-                s->reordered_input_picture[i+1]->coded_picture_number= coded_pic_num;
+                s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++;
             }
         }
     }
@@ -1839,8 +1833,6 @@
         }
     }
 
-    s->input_picture_number++;
-
     flush_put_bits(&s->pb);
     s->frame_bits  = (pbBufPtr(&s->pb) - s->pb.buf) * 8;
 
--- a/mpegvideo.h	Sun Dec 28 11:35:54 2003 +0000
+++ b/mpegvideo.h	Mon Dec 29 22:25:08 2003 +0000
@@ -260,8 +260,9 @@
 
     /* sequence parameters */
     int context_initialized;
-    int input_picture_number;
-    int picture_number;
+    int input_picture_number;  ///< used to set pic->display_picture_number, shouldnt be used for/by anything else
+    int coded_picture_number;  ///< used to set pic->coded_picture_number, shouldnt be used for/by anything else
+    int picture_number;       //FIXME remove, unclear definition
     int picture_in_gop_number; ///< 0-> first pic in gop, ... 
     int b_frames_since_non_b;  ///< used for encoding, relative to not yet reordered input 
     int mb_width, mb_height;   ///< number of MBs horizontally & vertically 
--- a/ratecontrol.c	Sun Dec 28 11:35:54 2003 +0000
+++ b/ratecontrol.c	Mon Dec 29 22:25:08 2003 +0000
@@ -39,7 +39,7 @@
 
 void ff_write_pass1_stats(MpegEncContext *s){
     sprintf(s->avctx->stats_out, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n",
-            s->picture_number, s->input_picture_number - s->max_b_frames, s->pict_type, 
+            s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type, 
             s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, 
             s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count);
 }