changeset 1687:cdc3d4106fb6 libavcodec

cleanup
author michael
date Sat, 13 Dec 2003 20:41:33 +0000
parents 68abbec33289
children 04b759af8bd4
files h263dec.c mpegvideo.c mpegvideo.h ratecontrol.c
diffstat 4 files changed, 12 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/h263dec.c	Sat Dec 13 02:14:18 2003 +0000
+++ b/h263dec.c	Sat Dec 13 20:41:33 2003 +0000
@@ -85,7 +85,6 @@
         s->msmpeg4_version=5;
         break;
     case CODEC_ID_H263I:
-        s->h263_intel = 1;
         break;
     case CODEC_ID_FLV1:
         s->h263_flv = 1;
@@ -460,7 +459,7 @@
 
         if(s->flags& CODEC_FLAG_LOW_DELAY)
             s->low_delay=1;
-    } else if (s->h263_intel) {
+    } else if (s->codec_id == CODEC_ID_H263I) {
         ret = intel_h263_decode_picture_header(s);
     } else if (s->h263_flv) {
         ret = flv_h263_decode_picture_header(s);
--- a/mpegvideo.c	Sat Dec 13 02:14:18 2003 +0000
+++ b/mpegvideo.c	Sat Dec 13 20:41:33 2003 +0000
@@ -634,7 +634,6 @@
     avctx->pix_fmt = PIX_FMT_YUV420P; // FIXME
 
     s->bit_rate = avctx->bit_rate;
-    s->bit_rate_tolerance = avctx->bit_rate_tolerance;
     s->width = avctx->width;
     s->height = avctx->height;
     if(avctx->gop_size > 600){
@@ -642,13 +641,9 @@
         avctx->gop_size=600;
     }
     s->gop_size = avctx->gop_size;
-    s->max_qdiff= avctx->max_qdiff;
-    s->qcompress= avctx->qcompress;
-    s->qblur= avctx->qblur;
     s->avctx = avctx;
     s->flags= avctx->flags;
     s->max_b_frames= avctx->max_b_frames;
-    s->b_frame_strategy= avctx->b_frame_strategy;
     s->codec_id= avctx->codec->id;
     s->luma_elim_threshold  = avctx->luma_elim_threshold;
     s->chroma_elim_threshold= avctx->chroma_elim_threshold;
@@ -1683,10 +1678,10 @@
                     av_log(s->avctx, AV_LOG_ERROR, "warning, too many bframes in a row\n");
                     b_frames = s->max_b_frames;
                 }
-            }else if(s->b_frame_strategy==0){
+            }else if(s->avctx->b_frame_strategy==0){
                 b_frames= s->max_b_frames;
                 while(b_frames && !s->input_picture[b_frames]) b_frames--;
-            }else if(s->b_frame_strategy==1){
+            }else if(s->avctx->b_frame_strategy==1){
                 for(i=1; i<s->max_b_frames+1; i++){
                     if(s->input_picture[i] && s->input_picture[i]->b_frame_score==0){
                         s->input_picture[i]->b_frame_score= 
--- a/mpegvideo.h	Sat Dec 13 02:14:18 2003 +0000
+++ b/mpegvideo.h	Sat Dec 13 20:41:33 2003 +0000
@@ -236,25 +236,19 @@
     int gop_size;
     int intra_only;   ///< if true, only intra pictures are generated 
     int bit_rate;     ///< wanted bit rate 
-    int bit_rate_tolerance; ///< amount of +- bits (>0)
     enum OutputFormat out_format; ///< output format 
     int h263_pred;    ///< use mpeg4/h263 ac/dc predictions 
 
 /* the following codec id fields are deprecated in favor of codec_id */
     int h263_plus;    ///< h263 plus headers 
     int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
-    int h263_intel;   ///< use I263 intel h263 header 
     int h263_flv;     ///< use flv h263 header 
     
     int codec_id;     /* see CODEC_ID_xxx */
     int fixed_qscale; ///< fixed qscale if non zero 
-    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0) 
-    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
-    int max_qdiff;    ///< max qscale difference between frames 
     int encoding;     ///< true if we are encoding (vs decoding) 
     int flags;        ///< AVCodecContext.flags (HQ, MV4, ...) 
     int max_b_frames; ///< max number of b-frames for encoding 
-    int b_frame_strategy;
     int luma_elim_threshold;
     int chroma_elim_threshold;
     int strict_std_compliance; ///< strictly follow the std (MPEG4, ...) 
--- a/ratecontrol.c	Sat Dec 13 02:14:18 2003 +0000
+++ b/ratecontrol.c	Sat Dec 13 20:41:33 2003 +0000
@@ -236,6 +236,7 @@
  */
 static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num){
     RateControlContext *rcc= &s->rc_context;
+    AVCodecContext *a= s->avctx;
     double q, bits;
     const int pict_type= rce->new_pict_type;
     const double mb_num= s->mb_num;  
@@ -256,7 +257,7 @@
         rce->pict_type == P_TYPE,
         rce->pict_type == B_TYPE,
         rcc->qscale_sum[pict_type] / (double)rcc->frame_count[pict_type],
-        s->qcompress,
+        a->qcompress,
 /*        rcc->last_qscale_for[I_TYPE],
         rcc->last_qscale_for[P_TYPE],
         rcc->last_qscale_for[B_TYPE],
@@ -577,6 +578,7 @@
     int picture_number= s->picture_number;
     int64_t wanted_bits;
     RateControlContext *rcc= &s->rc_context;
+    AVCodecContext *a= s->avctx;
     RateControlEntry local_rce, *rce;
     double bits;
     double rate_factor;
@@ -606,7 +608,7 @@
     }
 
     diff= s->total_bits - wanted_bits;
-    br_compensation= (s->bit_rate_tolerance - diff)/s->bit_rate_tolerance;
+    br_compensation= (a->bit_rate_tolerance - diff)/a->bit_rate_tolerance;
     if(br_compensation<=0.0) br_compensation=0.001;
 
     var= pict_type == I_TYPE ? pic->mb_var_sum : pic->mc_mb_var_sum;
@@ -658,8 +660,8 @@
         assert(q>0.0);
 
         if(pict_type==P_TYPE || s->intra_only){ //FIXME type dependant blur like in 2-pass
-            rcc->short_term_qsum*=s->qblur;
-            rcc->short_term_qcount*=s->qblur;
+            rcc->short_term_qsum*=a->qblur;
+            rcc->short_term_qcount*=a->qblur;
 
             rcc->short_term_qsum+= q;
             rcc->short_term_qcount++;
@@ -711,6 +713,7 @@
 static int init_pass2(MpegEncContext *s)
 {
     RateControlContext *rcc= &s->rc_context;
+    AVCodecContext *a= s->avctx;
     int i;
     double fps= (double)s->avctx->frame_rate / (double)s->avctx->frame_rate_base;
     double complexity[5]={0,0,0,0,0};   // aproximate bits at quant=1
@@ -722,7 +725,7 @@
     double rate_factor=0;
     double step;
     //int last_i_frame=-10000000;
-    const int filter_size= (int)(s->qblur*4) | 1;  
+    const int filter_size= (int)(a->qblur*4) | 1;  
     double expected_bits;
     double *qscale, *blured_qscale;
 
@@ -803,7 +806,7 @@
             for(j=0; j<filter_size; j++){
                 int index= i+j-filter_size/2;
                 double d= index-i;
-                double coeff= s->qblur==0 ? 1.0 : exp(-d*d/(s->qblur * s->qblur));
+                double coeff= a->qblur==0 ? 1.0 : exp(-d*d/(a->qblur * a->qblur));
             
                 if(index < 0 || index >= rcc->num_entries) continue;
                 if(pict_type != rcc->entry[index].new_pict_type) continue;