[cvs] / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/encoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.117, Sun Mar 27 03:59:42 2005 UTC revision 1.118, Mon May 23 09:29:43 2005 UTC
# Line 85  Line 85 
85  /*  /*
86   * Simplify the "fincr/fbase" fraction   * Simplify the "fincr/fbase" fraction
87  */  */
88    static int
89    gcd(int a, int b)
90    {
91            int r ;
92    
93            if (b > a) {
94                    r = a;
95                    a = b;
96                    b = r;
97            }
98    
99            while ((r = a % b)) {
100                    a = b;
101                    b = r;
102            }
103            return b;
104    }
105    
106  static void  static void
107  simplify_time(int *inc, int *base)  simplify_time(int *inc, int *base)
108  {  {
109          /* common factor */          /* common factor */
110          int i = *inc;          const int s = gcd(*inc, *base);
111          while (i > 1) {    *inc  /= s;
112                  if (*inc % i == 0 && *base % i == 0) {    *base /= s;
                         *inc /= i;  
                         *base /= i;  
                         i = *inc;  
                         continue;  
                 }  
                 i--;  
         }  
113    
114          if (*base > 65535 || *inc > 65535) {          if (*base > 65535 || *inc > 65535) {
115                  int *biggest;                  int *biggest;
# Line 114  Line 125 
125                  }                  }
126    
127                  div = ((float)*biggest)/((float)65535);                  div = ((float)*biggest)/((float)65535);
128                  *biggest = (int)(((float)*biggest)/div);                  *biggest = (unsigned int)(((float)*biggest)/div);
129                  *other = (int)(((float)*other)/div);                  *other = (unsigned int)(((float)*other)/div);
130          }          }
131  }  }
132    
# Line 161  Line 172 
172          pEnc->mbParam.fincr = MAX(create->fincr, 0);          pEnc->mbParam.fincr = MAX(create->fincr, 0);
173          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;
174          if (pEnc->mbParam.fincr>0)          if (pEnc->mbParam.fincr>0)
175                  simplify_time(&pEnc->mbParam.fincr, &pEnc->mbParam.fbase);                  simplify_time((int*)&pEnc->mbParam.fincr, (int*)&pEnc->mbParam.fbase);
176    
177          /* zones */          /* zones */
178          if(create->num_zones > 0) {          if(create->num_zones > 0) {
# Line 874  Line 885 
885  #endif  #endif
886  }  }
887    
 static int  
 gcd(int a, int b)  
 {  
         int r ;  
   
         if (b > a) {  
                 r = a;  
                 a = b;  
                 b = r;  
         }  
   
         while ((r = a % b)) {  
                 a = b;  
                 b = r;  
         }  
         return b;  
 }  
   
888  static void  static void
889  simplify_par(int *par_width, int *par_height)  simplify_par(int *par_width, int *par_height)
890  {  {
# Line 1155  Line 1148 
1148          type = frame->type;          type = frame->type;
1149          pEnc->current->quant = frame->quant;          pEnc->current->quant = frame->quant;
1150    
1151          call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_BEFORE, &type, &pEnc->current->quant, stats);          call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_BEFORE, &type, (int*)&pEnc->current->quant, stats);
1152    
1153          if (type > 0){  /* XVID_TYPE_?VOP */          if (type > 0){  /* XVID_TYPE_?VOP */
1154                  type = type2coding(type);       /* convert XVID_TYPE_?VOP to bitstream coding type */                  type = type2coding(type);       /* convert XVID_TYPE_?VOP to bitstream coding type */

Legend:
Removed from v.1.117  
changed lines
  Added in v.1.118

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4