changeset 1163:0951691c4225 libavcodec

fixing msmpeg4v2 encoding
author michaelni
date Tue, 01 Apr 2003 15:38:01 +0000
parents 8c15d82c1893
children 0e3c0c4a7b3d
files mpegvideo.c msmpeg4.c wmv2.c
diffstat 3 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Mon Mar 31 11:13:14 2003 +0000
+++ b/mpegvideo.c	Tue Apr 01 15:38:01 2003 +0000
@@ -648,6 +648,7 @@
         s->h263_pred = 1;
         s->unrestricted_mv = 1;
         s->msmpeg4_version= 3;
+        s->flipflop_rounding=1;
         avctx->delay=0;
         s->low_delay=1;
         break;
@@ -657,6 +658,7 @@
         s->h263_pred = 1;
         s->unrestricted_mv = 1;
         s->msmpeg4_version= 4;
+        s->flipflop_rounding=1;
         avctx->delay=0;
         s->low_delay=1;
         break;
@@ -666,6 +668,7 @@
         s->h263_pred = 1;
         s->unrestricted_mv = 1;
         s->msmpeg4_version= 5;
+        s->flipflop_rounding=1;
         avctx->delay=0;
         s->low_delay=1;
         break;
@@ -2834,8 +2837,8 @@
     s->qscale= (int)(s->frame_qscale + 0.5); //FIXME qscale / ... stuff for ME ratedistoration
     
     if(s->pict_type==I_TYPE){
-        if(s->msmpeg4_version) s->no_rounding=1;
-        else                   s->no_rounding=0;
+        if(s->msmpeg4_version >= 3) s->no_rounding=1;
+        else                        s->no_rounding=0;
     }else if(s->pict_type!=B_TYPE){
         if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
             s->no_rounding ^= 1;          
--- a/msmpeg4.c	Mon Mar 31 11:13:14 2003 +0000
+++ b/msmpeg4.c	Tue Apr 01 15:38:01 2003 +0000
@@ -439,12 +439,10 @@
 
         put_bits(&s->pb, 11, FFMIN(s->bit_rate/1024, 2047));
 
-        if(s->msmpeg4_version<3)
-            s->flipflop_rounding=0;
-        else{
-            s->flipflop_rounding=1;
+        if(s->msmpeg4_version>=3)
             put_bits(&s->pb, 1, s->flipflop_rounding);
-        }
+        else
+            assert(s->flipflop_rounding==0);
 }
 
 #endif //CONFIG_ENCODERS
--- a/wmv2.c	Mon Mar 31 11:13:14 2003 +0000
+++ b/wmv2.c	Tue Apr 01 15:38:01 2003 +0000
@@ -131,7 +131,10 @@
     w->abt_type=0;
     w->j_type=0;
 
+    assert(s->flipflop_rounding);
+
     if (s->pict_type == I_TYPE) {
+        assert(s->no_rounding==1);
         if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type);
         
         if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table);
@@ -144,7 +147,6 @@
         put_bits(&s->pb, 1, s->dc_table_index);
 
         s->inter_intra_pred= 0;
-        s->no_rounding = 1;
     }else{
         int cbp_index;
 
@@ -181,7 +183,6 @@
         put_bits(&s->pb, 1, s->mv_table_index);
     
         s->inter_intra_pred= (s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE);
-        s->no_rounding ^= 1;
     }
     s->esc3_level_length= 0;
     s->esc3_run_length= 0;