changeset 1617:8b31f3a3e9fa libavcodec

ac prediction with rate distorted qp fix
author michael
date Wed, 12 Nov 2003 13:03:51 +0000
parents 13a20c0594f2
children bccc4a9fcb3b
files mpegvideo.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mpegvideo.c	Wed Nov 12 12:25:44 2003 +0000
+++ b/mpegvideo.c	Wed Nov 12 13:03:51 2003 +0000
@@ -3834,6 +3834,7 @@
                     if(best_s.mv_type==MV_TYPE_16X16 && !(best_s.mv_dir&MV_DIRECT)){
                         const int last_qp= backup_s.qscale;
                         int dquant, dir, qp, dc[6];
+                        DCTELEM ac[6][16];
                         
                         assert(backup_s.dquant == 0);
 
@@ -3853,15 +3854,21 @@
                             if(qp < s->avctx->qmin || qp > s->avctx->qmax)
                                 break;
                             backup_s.dquant= dquant;
-                            for(i=0; i<6; i++){
-                                dc[i]= s->dc_val[0][ s->block_index[i] ]; //FIXME AC
+                            if(s->mb_intra){
+                                for(i=0; i<6; i++){
+                                    dc[i]= s->dc_val[0][ s->block_index[i] ];
+                                    memcpy(ac[i], s->ac_val[0][s->block_index[i]], sizeof(DCTELEM)*16);
+                                }
                             }
-//printf("%d %d\n", backup_s.dquant, backup_s.qscale);
+
                             encode_mb_hq(s, &backup_s, &best_s, MB_TYPE_INTER /* wrong but unused */, pb, pb2, tex_pb, 
                                          &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
                             if(best_s.qscale != qp){
-                                for(i=0; i<6; i++){
-                                    s->dc_val[0][ s->block_index[i] ]= dc[i];
+                                if(s->mb_intra){
+                                    for(i=0; i<6; i++){
+                                        s->dc_val[0][ s->block_index[i] ]= dc[i];
+                                        memcpy(s->ac_val[0][s->block_index[i]], ac[i], sizeof(DCTELEM)*16);
+                                    }
                                 }
                                 if(dir > 0 && dquant==dir){
                                     dquant= 0;