changeset 1652:834922115010 libavcodec

cleanup
author michael
date Wed, 03 Dec 2003 16:47:17 +0000
parents ccf7c96a630f
children 11433ade9e06
files h263.c h263dec.c mpegvideo.c mpegvideo.h rv10.c
diffstat 5 files changed, 26 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/h263.c	Wed Dec 03 16:07:41 2003 +0000
+++ b/h263.c	Wed Dec 03 16:47:17 2003 +0000
@@ -2239,20 +2239,19 @@
 #endif //CONFIG_ENCODERS
 
 /**
- * change qscale by given dquant and update qscale dependant variables.
+ * set qscale and update qscale dependant variables.
  */
-static void change_qscale(MpegEncContext * s, int dquant)
+void ff_set_qscale(MpegEncContext * s, int qscale)
 {
-    s->qscale += dquant;
-
-    if (s->qscale < 1)
-        s->qscale = 1;
-    else if (s->qscale > 31)
-        s->qscale = 31;
+    if (qscale < 1)
+        qscale = 1;
+    else if (qscale > 31)
+        qscale = 31;
         
-    s->chroma_qscale= s->chroma_qscale_table[s->qscale];
-
-    s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
+    s->qscale = qscale;
+    s->chroma_qscale= s->chroma_qscale_table[qscale];
+
+    s->y_dc_scale= s->y_dc_scale_table[ qscale ];
     s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
 }
 
@@ -2746,7 +2745,6 @@
     s->qscale = get_bits(&s->gb, 5); /* GQUANT */
     if(s->qscale==0) 
         return -1;
-    s->chroma_qscale= s->chroma_qscale_table[s->qscale];
 
     s->mb_x= 0;
     s->mb_y= s->gob_index* s->gob_number;
@@ -3123,7 +3121,7 @@
                 s->mb_intra = 1;
 
                 if(cbpc & 4) {
-                    change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
+                    ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
                 }
                 s->current_picture.qscale_table[xy]= s->qscale;
 
@@ -3286,7 +3284,7 @@
                     }
                     
                     if(s->cbp_table[xy] & 8) {
-                        change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
+                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
                     }
                     s->current_picture.qscale_table[xy]= s->qscale;
 
@@ -3316,7 +3314,7 @@
                     }
                     
                     if(s->cbp_table[xy] & 8) {
-                        change_qscale(s, quant_tab[get_bits(&s->gb, 2)]);
+                        ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
                     }
                     s->current_picture.qscale_table[xy]= s->qscale;
 
@@ -3393,9 +3391,7 @@
     cbp = s->cbp_table[xy];
 
     if(s->current_picture.qscale_table[xy] != s->qscale){
-        s->chroma_qscale=s->qscale= s->current_picture.qscale_table[xy];
-        s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-        s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
+        ff_set_qscale(s, s->current_picture.qscale_table[xy] );
     }
     
     if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
@@ -3608,7 +3604,7 @@
                     s->qscale= get_bits(&s->gb, 5);
             }else
                 s->qscale += quant_tab[get_bits(&s->gb, 2)];
-            change_qscale(s, 0);
+            ff_set_qscale(s, s->qscale);
         }
         
         s->mv_dir = MV_DIR_FORWARD;
@@ -3700,7 +3696,7 @@
                     s->qscale= get_bits(&s->gb, 5);
             }else
                 s->qscale += quant_tab[get_bits(&s->gb, 2)];
-            change_qscale(s, 0);
+            ff_set_qscale(s, s->qscale);
         }
         
         /* decode each block */
@@ -3793,8 +3789,7 @@
         
         cbp = (cbpc & 3) | (cbpy << 2);
         if (dquant) {
-            s->qscale += quant_tab[get_bits(&s->gb, 2)];
-            change_qscale(s, 0);
+            ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
         }
         if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE)))
             s->interlaced_dct= get_bits1(&s->gb);
@@ -3918,7 +3913,7 @@
 
             if ((!IS_DIRECT(mb_type)) && cbp) {
                 if(get_bits1(&s->gb)){
-                    change_qscale(s, get_bits1(&s->gb)*4 - 2);
+                    ff_set_qscale(s, s->qscale + get_bits1(&s->gb)*4 - 2);
                 }
             }
 
@@ -4026,8 +4021,7 @@
         }
         cbp = (cbpc & 3) | (cbpy << 2);
         if (dquant) {
-            s->qscale += quant_tab[get_bits(&s->gb, 2)];
-            change_qscale(s, 0);
+            ff_set_qscale(s, s->qscale + quant_tab[get_bits(&s->gb, 2)]);
         }
         
         if(!s->progressive_sequence)
@@ -4749,7 +4743,6 @@
         }
             
         s->qscale = get_bits(&s->gb, 5);
-        s->chroma_qscale= s->chroma_qscale_table[s->qscale];
     }
     /* PEI */
     while (get_bits1(&s->gb) != 0) {
--- a/h263dec.c	Wed Dec 03 16:07:41 2003 +0000
+++ b/h263dec.c	Wed Dec 03 16:47:17 2003 +0000
@@ -146,8 +146,7 @@
     s->resync_mb_x= s->mb_x;
     s->resync_mb_y= s->mb_y;
 
-    s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-    s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
+    ff_set_qscale(s, s->qscale);
     
     if(s->partitioned_frame){
         const int qscale= s->qscale;
@@ -161,9 +160,7 @@
         s->first_slice_line=1;
         s->mb_x= s->resync_mb_x;
         s->mb_y= s->resync_mb_y;
-        s->chroma_qscale= s->qscale= qscale;
-        s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-        s->c_dc_scale= s->c_dc_scale_table[ s->qscale ];
+        ff_set_qscale(s, qscale);
     }
 
     for(; s->mb_y < s->mb_height; s->mb_y++) {
--- a/mpegvideo.c	Wed Dec 03 16:07:41 2003 +0000
+++ b/mpegvideo.c	Wed Dec 03 16:47:17 2003 +0000
@@ -3123,10 +3123,7 @@
                 }
             }
         }
-        s->qscale= last_qp + s->dquant;
-        s->chroma_qscale= s->chroma_qscale_table[ s->qscale ];
-        s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-        s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
+        ff_set_qscale(s, last_qp + s->dquant);
     }
 
     if (s->mb_intra) {
@@ -3864,9 +3861,7 @@
         s->mb_x=0;
         s->mb_y= mb_y;
 
-        s->chroma_qscale= s->chroma_qscale_table[ s->qscale ];
-        s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-        s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
+        ff_set_qscale(s, s->qscale);
         ff_init_block_index(s);
         
         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
--- a/mpegvideo.h	Wed Dec 03 16:07:41 2003 +0000
+++ b/mpegvideo.h	Wed Dec 03 16:47:17 2003 +0000
@@ -825,6 +825,7 @@
 extern const uint8_t ff_h263_chroma_qscale_table[32];
 extern const uint8_t ff_h263_loop_filter_strength[32];
 
+
 int ff_h263_decode_init(AVCodecContext *avctx);
 int ff_h263_decode_frame(AVCodecContext *avctx, 
                              void *data, int *data_size,
@@ -852,6 +853,7 @@
 int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
 void ff_h263_update_motion_val(MpegEncContext * s);
 int ff_h263_loop_filter(MpegEncContext * s);
+void ff_set_qscale(MpegEncContext * s, int qscale);
 
 
 int intel_h263_decode_picture_header(MpegEncContext *s);
--- a/rv10.c	Wed Dec 03 16:07:41 2003 +0000
+++ b/rv10.c	Wed Dec 03 16:47:17 2003 +0000
@@ -527,9 +527,7 @@
     if(s->modified_quant)
         s->chroma_qscale_table= ff_h263_chroma_qscale_table;
         
-    s->chroma_qscale= s->chroma_qscale_table[ s->qscale ];
-    s->y_dc_scale= s->y_dc_scale_table[ s->qscale ];
-    s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
+    ff_set_qscale(s, s->qscale);
 
     s->rv10_first_dc_coded[0] = 0;
     s->rv10_first_dc_coded[1] = 0;