changeset 1805:5dd5b2052f5b libavcodec

mpeg4 b frame + adaptive quantization assertion failure fix
author michael
date Sat, 14 Feb 2004 03:49:43 +0000
parents cc0a15943a87
children 2721e1859e19
files mpegvideo.c
diffstat 1 files changed, 13 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Sat Feb 14 03:21:03 2004 +0000
+++ b/mpegvideo.c	Sat Feb 14 03:49:43 2004 +0000
@@ -3412,13 +3412,20 @@
         if(!(s->flags&CODEC_FLAG_QP_RD)){
             s->dquant= s->qscale - last_qp;
 
-            if(s->out_format==FMT_H263)
+            if(s->out_format==FMT_H263){
                 s->dquant= clip(s->dquant, -2, 2); //FIXME RD
             
-            if(s->codec_id==CODEC_ID_MPEG4){        
-                if(!s->mb_intra){
-                    if((s->mv_dir&MV_DIRECT) || s->mv_type==MV_TYPE_8X8)
-                        s->dquant=0;
+                if(s->codec_id==CODEC_ID_MPEG4){        
+                    if(!s->mb_intra){
+                        if(s->pict_type == B_TYPE){
+                            if(s->dquant&1) 
+                                s->dquant= (s->dquant/2)*2;
+                            if(s->mv_dir&MV_DIRECT)
+                                s->dquant= 0;
+                        }
+                        if(s->mv_type==MV_TYPE_8X8)
+                            s->dquant=0;
+                    }
                 }
             }
         }
@@ -3969,6 +3976,7 @@
             s->mb_var_sum_temp    += varc;
         }
     }
+    return 0;
 }
 
 static void write_slice_end(MpegEncContext *s){