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

Diff of /xvidcore/src/motion/motion_est.c

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

revision 1.44.2.50, Thu Feb 6 09:25:37 2003 UTC revision 1.61, Sat Mar 29 10:57:29 2003 UTC
# Line 44  Line 44 
44  #include "motion.h"  #include "motion.h"
45  #include "sad.h"  #include "sad.h"
46  #include "../utils/emms.h"  #include "../utils/emms.h"
47    #include "../dct/fdct.h"
48    
49    /*****************************************************************************
50     * Modified rounding tables -- declared in motion.h
51     * Original tables see ISO spec tables 7-6 -> 7-9
52     ****************************************************************************/
53    
54    const uint32_t roundtab[16] =
55    {0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2 };
56    
57    /* K = 4 */
58    const uint32_t roundtab_76[16] =
59    { 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1 };
60    
61    /* K = 2 */
62    const uint32_t roundtab_78[8] =
63    { 0, 0, 1, 1, 0, 0, 0, 1  };
64    
65    /* K = 1 */
66    const uint32_t roundtab_79[4] =
67    { 0, 1, 0, 0 };
68    
69  #define INITIAL_SKIP_THRESH     (10)  #define INITIAL_SKIP_THRESH     (10)
70  #define FINAL_SKIP_THRESH       (50)  #define FINAL_SKIP_THRESH       (50)
# Line 51  Line 72 
72  #define MAX_CHROMA_SAD_FOR_SKIP (22)  #define MAX_CHROMA_SAD_FOR_SKIP (22)
73    
74  #define CHECK_CANDIDATE(X,Y,D) { \  #define CHECK_CANDIDATE(X,Y,D) { \
75  (*CheckCandidate)((const int)(X),(const int)(Y), (D), &iDirection, data ); }  CheckCandidate((X),(Y), (D), &iDirection, data ); }
76    
77    /*****************************************************************************
78     * Code
79     ****************************************************************************/
80    
81  static __inline uint32_t  static __inline uint32_t
82  d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv)  d_mv_bits(int x, int y, const VECTOR pred, const uint32_t iFcode, const int qpel, const int rrv)
# Line 359  Line 384 
384                  || (y > data->max_dy) || (y < data->min_dy) ) return;                  || (y > data->max_dy) || (y < data->min_dy) ) return;
385    
386          if (!data->qpel_precision) Reference = GetReference(x, y, data);          if (!data->qpel_precision) Reference = GetReference(x, y, data);
387          else Reference = Interpolate16x16qpel(x, y, 0, data);          else Reference = Interpolate8x8qpel(x, y, 0, 0, data);
388    
389          sad = sad8(data->Cur, Reference, data->iEdgedWidth);          sad = sad8(data->Cur, Reference, data->iEdgedWidth);
390          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);          t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);
# Line 438  Line 463 
463          if (data->chroma) sad += ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3],          if (data->chroma) sad += ChromaSAD((xc >> 1) + roundtab_79[xc & 0x3],
464                                                                                  (yc >> 1) + roundtab_79[yc & 0x3], data);                                                                                  (yc >> 1) + roundtab_79[yc & 0x3], data);
465    
   
466          if (sad < *(data->iMinSAD)) {          if (sad < *(data->iMinSAD)) {
467                  *(data->iMinSAD) = sad;                  *(data->iMinSAD) = sad;
468                  current->x = x; current->y = y;                  current->x = x; current->y = y;
# Line 482  Line 506 
506          const uint8_t *ReferenceF, *ReferenceB;          const uint8_t *ReferenceF, *ReferenceB;
507          VECTOR *current;          VECTOR *current;
508    
509          if ( (xf > data->max_dx) | (xf < data->min_dx)          if ( (xf > data->max_dx) || (xf < data->min_dx)
510                  | (yf > data->max_dy) | (yf < data->min_dy) ) return;                  || (yf > data->max_dy) || (yf < data->min_dy) ) return;
511    
512          if (!data->qpel_precision) {          if (!data->qpel_precision) {
513                  ReferenceF = GetReference(xf, yf, data);                  ReferenceF = GetReference(xf, yf, data);
# Line 528  Line 552 
552          const uint8_t *ReferenceB;          const uint8_t *ReferenceB;
553          VECTOR mvs, b_mvs;          VECTOR mvs, b_mvs;
554    
555          if (( x > 31) | ( x < -32) | ( y > 31) | (y < -32)) return;          if (( x > 31) || ( x < -32) || ( y > 31) || (y < -32)) return;
556    
557          for (k = 0; k < 4; k++) {          for (k = 0; k < 4; k++) {
558                  mvs.x = data->directmvF[k].x + x;                  mvs.x = data->directmvF[k].x + x;
# Line 541  Line 565 
565                          data->directmvB[k].y                          data->directmvB[k].y
566                          : mvs.y - data->referencemv[k].y);                          : mvs.y - data->referencemv[k].y);
567    
568                  if ( (mvs.x > data->max_dx) | (mvs.x < data->min_dx)                  if ( (mvs.x > data->max_dx) || (mvs.x < data->min_dx)
569                          | (mvs.y > data->max_dy) | (mvs.y < data->min_dy)                          || (mvs.y > data->max_dy) || (mvs.y < data->min_dy)
570                          | (b_mvs.x > data->max_dx) | (b_mvs.x < data->min_dx)                          || (b_mvs.x > data->max_dx) || (b_mvs.x < data->min_dx)
571                          | (b_mvs.y > data->max_dy) | (b_mvs.y < data->min_dy) ) return;                          || (b_mvs.y > data->max_dy) || (b_mvs.y < data->min_dy) ) return;
572    
573                  if (data->qpel) {                  if (data->qpel) {
574                          xcf += mvs.x/2; ycf += mvs.y/2;                          xcf += mvs.x/2; ycf += mvs.y/2;
# Line 630  Line 654 
654          }          }
655  }  }
656    
657    
658    static void
659    CheckCandidateBits16(const int x, const int y, const int Direction, int * const dir, const SearchData * const data)
660    {
661    
662            int16_t *in = data->dctSpace, *coeff = data->dctSpace + 64;
663            int32_t bits = 0, sum;
664            VECTOR * current;
665            const uint8_t * ptr;
666            int i, cbp = 0, t, xc, yc;
667    
668            if ( (x > data->max_dx) || (x < data->min_dx)
669                    || (y > data->max_dy) || (y < data->min_dy) ) return;
670    
671            if (!data->qpel_precision) {
672                    ptr = GetReference(x, y, data);
673                    current = data->currentMV;
674                    xc = x; yc = y;
675            } else { // x and y are in 1/4 precision
676                    ptr = Interpolate16x16qpel(x, y, 0, data);
677                    current = data->currentQMV;
678                    xc = x/2; yc = y/2;
679            }
680    
681            for(i = 0; i < 4; i++) {
682                    int s = 8*((i&1) + (i>>1)*data->iEdgedWidth);
683                    transfer_8to16subro(in, data->Cur + s, ptr + s, data->iEdgedWidth);
684                    fdct(in);
685                    if (data->lambda8 == 0) sum = quant_inter(coeff, in, data->lambda16);
686                    else sum = quant4_inter(coeff, in, data->lambda16);
687                    if (sum > 0) {
688                            cbp |= 1 << (5 - i);
689                            bits += data->temp[i] = CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
690                    } else data->temp[i] = 0;
691            }
692    
693            bits += t = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);
694    
695            if (bits < data->iMinSAD[0]) { // there is still a chance, adding chroma
696                    xc = (xc >> 1) + roundtab_79[xc & 0x3];
697                    yc = (yc >> 1) + roundtab_79[yc & 0x3];
698    
699                    //chroma U
700                    ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefCU, 0, 0, xc, yc,  data->iEdgedWidth/2, data->rounding);
701                    transfer_8to16subro(in, ptr, data->CurU, data->iEdgedWidth/2);
702                    fdct(in);
703                    if (data->lambda8 == 0) sum = quant_inter(coeff, in, data->lambda16);
704                    else sum = quant4_inter(coeff, in, data->lambda16);
705                    if (sum > 0) {
706                            cbp |= 1 << (5 - 4);
707                            bits += CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
708                    }
709    
710                    if (bits < data->iMinSAD[0]) {
711                            //chroma V
712                            ptr = interpolate8x8_switch2(data->RefQ + 64, data->RefCV, 0, 0, xc, yc,  data->iEdgedWidth/2, data->rounding);
713                            transfer_8to16subro(in, ptr, data->CurV, data->iEdgedWidth/2);
714                            fdct(in);
715                            if (data->lambda8 == 0) sum = quant_inter(coeff, in, data->lambda16);
716                            else sum = quant4_inter(coeff, in, data->lambda16);
717                            if (sum > 0) {
718                                    cbp |= 1 << (5 - 5);
719                                    bits += CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
720                            }
721                    }
722            }
723    
724            bits += xvid_cbpy_tab[15-(cbp>>2)].len;
725            bits += mcbpc_inter_tab[(MODE_INTER & 7) | ((cbp & 3) << 3)].len;
726    
727            if (bits < data->iMinSAD[0]) {
728                    data->iMinSAD[0] = bits;
729                    current[0].x = x; current[0].y = y;
730                    *dir = Direction;
731            }
732    
733            if (data->temp[0] + t < data->iMinSAD[1]) {
734                    data->iMinSAD[1] = data->temp[0] + t; current[1].x = x; current[1].y = y; }
735            if (data->temp[1] < data->iMinSAD[2]) {
736                    data->iMinSAD[2] = data->temp[1]; current[2].x = x; current[2].y = y; }
737            if (data->temp[2] < data->iMinSAD[3]) {
738                    data->iMinSAD[3] = data->temp[2]; current[3].x = x; current[3].y = y; }
739            if (data->temp[3] < data->iMinSAD[4]) {
740                    data->iMinSAD[4] = data->temp[3]; current[4].x = x; current[4].y = y; }
741    
742    }
743    static void
744    CheckCandidateBits8(const int x, const int y, const int Direction, int * const dir, const SearchData * const data)
745    {
746    
747            int16_t *in = data->dctSpace, *coeff = data->dctSpace + 64;
748            int32_t sum, bits;
749            VECTOR * current;
750            const uint8_t * ptr;
751            int cbp;
752    
753            if ( (x > data->max_dx) || (x < data->min_dx)
754                    || (y > data->max_dy) || (y < data->min_dy) ) return;
755    
756            if (!data->qpel_precision) {
757                    ptr = GetReference(x, y, data);
758                    current = data->currentMV;
759            } else { // x and y are in 1/4 precision
760                    ptr = Interpolate8x8qpel(x, y, 0, 0, data);
761                    current = data->currentQMV;
762            }
763    
764            transfer_8to16subro(in, data->Cur, ptr, data->iEdgedWidth);
765            fdct(in);
766            if (data->lambda8 == 0) sum = quant_inter(coeff, in, data->lambda16);
767            else sum = quant4_inter(coeff, in, data->lambda16);
768            if (sum > 0) {
769                    bits = CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
770                    cbp = 1;
771            } else cbp = bits = 0;
772    
773            bits += sum = d_mv_bits(x, y, data->predMV, data->iFcode, data->qpel^data->qpel_precision, 0);
774    
775            if (bits < data->iMinSAD[0]) {
776                    data->temp[0] = cbp;
777                    data->iMinSAD[0] = bits;
778                    current[0].x = x; current[0].y = y;
779                    *dir = Direction;
780            }
781    }
782    
783  /* CHECK_CANDIATE FUNCTIONS END */  /* CHECK_CANDIATE FUNCTIONS END */
784    
785  /* MAINSEARCH FUNCTIONS START */  /* MAINSEARCH FUNCTIONS START */
# Line 845  Line 995 
995          uint32_t mb_width = pParam->mb_width;          uint32_t mb_width = pParam->mb_width;
996          uint32_t mb_height = pParam->mb_height;          uint32_t mb_height = pParam->mb_height;
997          const uint32_t iEdgedWidth = pParam->edged_width;          const uint32_t iEdgedWidth = pParam->edged_width;
998            const uint32_t MotionFlags = MakeGoodMotionFlags(current->motion_flags, current->global_flags);
999    
1000          uint32_t x, y;          uint32_t x, y;
1001          uint32_t iIntra = 0;          uint32_t iIntra = 0;
1002          int32_t InterBias, quant = current->quant, sad00;          int32_t quant = current->quant, sad00;
1003            int skip_thresh = INITIAL_SKIP_THRESH *
1004                    (current->global_flags & XVID_REDUCED ? 4:1) *
1005                    (current->global_flags & XVID_MODEDECISION_BITS ? 2:1);
1006    
1007          // some pre-initialized thingies for SearchP          // some pre-initialized thingies for SearchP
1008          int32_t temp[8];          int32_t temp[8];
1009          VECTOR currentMV[5];          VECTOR currentMV[5];
1010          VECTOR currentQMV[5];          VECTOR currentQMV[5];
1011          int32_t iMinSAD[5];          int32_t iMinSAD[5];
1012            DECLARE_ALIGNED_MATRIX(dct_space, 2, 64, int16_t, CACHE_LINE);
1013          SearchData Data;          SearchData Data;
1014          memset(&Data, 0, sizeof(SearchData));          memset(&Data, 0, sizeof(SearchData));
1015          Data.iEdgedWidth = iEdgedWidth;          Data.iEdgedWidth = iEdgedWidth;
# Line 865  Line 1020 
1020          Data.iFcode = current->fcode;          Data.iFcode = current->fcode;
1021          Data.rounding = pParam->m_rounding_type;          Data.rounding = pParam->m_rounding_type;
1022          Data.qpel = pParam->m_quarterpel;          Data.qpel = pParam->m_quarterpel;
1023          Data.chroma = current->motion_flags & PMV_CHROMA16;          Data.chroma = MotionFlags & PMV_CHROMA16;
1024          Data.rrv = current->global_flags & XVID_REDUCED;          Data.rrv = current->global_flags & XVID_REDUCED;
1025            Data.dctSpace = dct_space;
1026    
1027          if ((current->global_flags & XVID_REDUCED)) {          if ((current->global_flags & XVID_REDUCED)) {
1028                  mb_width = (pParam->width + 31) / 32;                  mb_width = (pParam->width + 31) / 32;
1029                  mb_height = (pParam->height + 31) / 32;                  mb_height = (pParam->height + 31) / 32;
1030                  Data.qpel = Data.chroma = 0;                  Data.qpel = 0;
1031          }          }
1032    
1033          Data.RefQ = pRefV->u; // a good place, also used in MC (for similar purpose)          Data.RefQ = pRefV->u; // a good place, also used in MC (for similar purpose)
# Line 915  Line 1071 
1071  //initial skip decision  //initial skip decision
1072  /* no early skip for GMC (global vector = skip vector is unknown!)  */  /* no early skip for GMC (global vector = skip vector is unknown!)  */
1073                          if (!(current->global_flags & XVID_GMC))        { /* no fast SKIP for S(GMC)-VOPs */                          if (!(current->global_flags & XVID_GMC))        { /* no fast SKIP for S(GMC)-VOPs */
1074                                  if (pMB->dquant == NO_CHANGE && sad00 < pMB->quant * INITIAL_SKIP_THRESH * (Data.rrv ? 4:1) )                                  if (pMB->dquant == NO_CHANGE && sad00 < pMB->quant * skip_thresh)
1075                                          if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {                                          if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {
1076                                                  SkipMacroblockP(pMB, sad00);                                                  SkipMacroblockP(pMB, sad00);
1077                                                  continue;                                                  continue;
# Line 923  Line 1079 
1079                          }                          }
1080    
1081                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,                          SearchP(pRef, pRefH->y, pRefV->y, pRefHV->y, pCurrent, x,
1082                                                  y, current->motion_flags, pMB->quant,                                                  y, MotionFlags, current->global_flags, pMB->quant,
1083                                                  &Data, pParam, pMBs, reference->mbs,                                                  &Data, pParam, pMBs, reference->mbs,
1084                                                  current->global_flags & XVID_INTER4V, pMB);                                                  current->global_flags & XVID_INTER4V, pMB);
1085    
1086  /* final skip decision, a.k.a. "the vector you found, really that good?" */  /* final skip decision, a.k.a. "the vector you found, really that good?" */
1087                          if (!(current->global_flags & XVID_GMC))        {                          if (!(current->global_flags & XVID_GMC || current->global_flags & XVID_MODEDECISION_BITS)) {
1088                                  if ( (pMB->dquant == NO_CHANGE) && (sad00 < pMB->quant * MAX_SAD00_FOR_SKIP)                                  if ( pMB->dquant == NO_CHANGE && sad00 < pMB->quant * MAX_SAD00_FOR_SKIP) {
1089                                          && ((100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1)) )                                          if ( (100*pMB->sad16)/(sad00+1) > FINAL_SKIP_THRESH * (Data.rrv ? 4:1) )
1090                                          if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv)) {                                                  if (Data.chroma || SkipDecisionP(pCurrent, pRef, x, y, iEdgedWidth/2, pMB->quant, Data.rrv))
1091                                                  SkipMacroblockP(pMB, sad00);                                                  SkipMacroblockP(pMB, sad00);
                                                 continue;  
                                         }  
                         }  
   
 /* finally, intra decision */  
   
                         InterBias = MV16_INTER_BIAS;  
                         if (pMB->quant > 8) InterBias += 100 * (pMB->quant - 8); // to make high quants work  
                         if (y != 0)  
                                 if ((pMB - pParam->mb_width)->mode == MODE_INTRA ) InterBias -= 80;  
                         if (x != 0)  
                                 if ((pMB - 1)->mode == MODE_INTRA ) InterBias -= 80;  
   
                         if (Data.chroma) InterBias += 50; // to compensate bigger SAD  
                         if (Data.rrv) InterBias *= 4;  
   
                         if (InterBias < pMB->sad16) {  
                                 int32_t deviation;  
                                 if (!Data.rrv)  
                                         deviation = dev16(pCurrent->y + (x + y * iEdgedWidth) * 16, iEdgedWidth);  
                                 else {  
                                         deviation = dev16(pCurrent->y + (x + y * iEdgedWidth) * 32, iEdgedWidth)  
                                                 + dev16(pCurrent->y + (x + y * iEdgedWidth) * 32 + 16, iEdgedWidth)  
                                                 + dev16(pCurrent->y + (x + y * iEdgedWidth) * 32 + 16 * iEdgedWidth, iEdgedWidth)  
                                                 + dev16(pCurrent->y + (x + y * iEdgedWidth) * 32 + 16 * (iEdgedWidth+1), iEdgedWidth);  
                                 }  
                                 if (deviation < (pMB->sad16 - InterBias)) {  
                                         if (++iIntra >= iLimit) return 1;  
                                         SkipMacroblockP(pMB, 0); //same thing  
                                         pMB->mode = MODE_INTRA;  
1092                                  }                                  }
1093                          }                          }
1094                            if (pMB->mode == MODE_INTRA)
1095                                    if (++iIntra > iLimit) return 1;
1096                  }                  }
1097          }          }
1098    
# Line 972  Line 1100 
1100          {          {
1101                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);                  current->warp = GlobalMotionEst( pMBs, pParam, current, reference, pRefH, pRefV, pRefHV);
1102          }          }
   
1103          return 0;          return 0;
1104  }  }
1105    
# Line 1036  Line 1163 
1163          }          }
1164  }  }
1165    
1166    static int
1167    ModeDecision(const uint32_t iQuant, SearchData * const Data,
1168                    int inter4v,
1169                    MACROBLOCK * const pMB,
1170                    const MACROBLOCK * const pMBs,
1171                    const int x, const int y,
1172                    const MBParam * const pParam,
1173                    const uint32_t MotionFlags,
1174                    const uint32_t GlobalFlags)
1175    {
1176    
1177            int mode = MODE_INTER;
1178    
1179            if (!(GlobalFlags & XVID_MODEDECISION_BITS)) { //normal, fast, SAD-based mode decision
1180    //              int intra = 0;
1181                    int sad;
1182                    int InterBias = MV16_INTER_BIAS;
1183                    if (inter4v == 0 || Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] +
1184                            Data->iMinSAD[3] + Data->iMinSAD[4] + IMV16X16 * (int32_t)iQuant) {
1185                                    mode = 0; //inter
1186                                    sad = Data->iMinSAD[0];
1187                    } else {
1188                            mode = MODE_INTER4V;
1189                            sad = Data->iMinSAD[1] + Data->iMinSAD[2] +
1190                                                    Data->iMinSAD[3] + Data->iMinSAD[4] + IMV16X16 * (int32_t)iQuant;
1191                            Data->iMinSAD[0] = sad;
1192                    }
1193    
1194                    /* intra decision */
1195    
1196                    if (iQuant > 8) InterBias += 100 * (iQuant - 8); // to make high quants work
1197                    if (y != 0)
1198                            if ((pMB - pParam->mb_width)->mode == MODE_INTRA ) InterBias -= 80;
1199                    if (x != 0)
1200                            if ((pMB - 1)->mode == MODE_INTRA ) InterBias -= 80;
1201    
1202                    if (Data->chroma) InterBias += 50; // to compensate bigger SAD
1203                    if (Data->rrv) InterBias *= 4;
1204    
1205                    if (InterBias < pMB->sad16) {
1206                            int32_t deviation;
1207                            if (!Data->rrv) deviation = dev16(Data->Cur, Data->iEdgedWidth);
1208                            else deviation = dev16(Data->Cur, Data->iEdgedWidth) +
1209                                    dev16(Data->Cur+8, Data->iEdgedWidth) +
1210                                    dev16(Data->Cur + 8*Data->iEdgedWidth, Data->iEdgedWidth) +
1211                                    dev16(Data->Cur+8+8*Data->iEdgedWidth, Data->iEdgedWidth);
1212    
1213                            if (deviation < (sad - InterBias))  return MODE_INTRA;// intra
1214                    }
1215                    return mode;
1216    
1217            } else {
1218    
1219                    int bits, intra, i;
1220                    VECTOR backup[5], *v;
1221                    Data->lambda16 = iQuant;
1222                    Data->lambda8 = pParam->m_quant_type;
1223    
1224                    v = Data->qpel ? Data->currentQMV : Data->currentMV;
1225                    for (i = 0; i < 5; i++) {
1226                            Data->iMinSAD[i] = 256*4096;
1227                            backup[i] = v[i];
1228                    }
1229    
1230                    bits = CountMBBitsInter(Data, pMBs, x, y, pParam, MotionFlags);
1231                    if (bits == 0) return MODE_INTER; // quick stop
1232    
1233                    if (inter4v) {
1234                            int inter4v = CountMBBitsInter4v(Data, pMB, pMBs, x, y, pParam, MotionFlags, backup);
1235                            if (inter4v < bits) { Data->iMinSAD[0] = bits = inter4v; mode = MODE_INTER4V; }
1236                    }
1237    
1238    
1239                    intra = CountMBBitsIntra(Data);
1240    
1241                    if (intra < bits) { *Data->iMinSAD = bits = intra; return MODE_INTRA; }
1242    
1243                    return mode;
1244            }
1245    }
1246    
1247  static void  static void
1248  SearchP(const IMAGE * const pRef,  SearchP(const IMAGE * const pRef,
1249                  const uint8_t * const pRefH,                  const uint8_t * const pRefH,
# Line 1045  Line 1253 
1253                  const int x,                  const int x,
1254                  const int y,                  const int y,
1255                  const uint32_t MotionFlags,                  const uint32_t MotionFlags,
1256                    const uint32_t GlobalFlags,
1257                  const uint32_t iQuant,                  const uint32_t iQuant,
1258                  SearchData * const Data,                  SearchData * const Data,
1259                  const MBParam * const pParam,                  const MBParam * const pParam,
# Line 1094  Line 1303 
1303          Data->iMinSAD[3] = pMB->sad8[2];          Data->iMinSAD[3] = pMB->sad8[2];
1304          Data->iMinSAD[4] = pMB->sad8[3];          Data->iMinSAD[4] = pMB->sad8[3];
1305    
1306          if (x | y) {          if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) || (x | y)) {
1307                  threshA = Data->temp[0]; // that's when we keep this SAD atm                  threshA = Data->temp[0]; // that's where we keep this SAD atm
1308                  if (threshA < 512) threshA = 512;                  if (threshA < 512) threshA = 512;
1309                  else if (threshA > 1024) threshA = 1024;                  else if (threshA > 1024) threshA = 1024;
1310          } else threshA = 512;          } else
1311                    threshA = 512;
1312    
1313          PreparePredictionsP(pmv, x, y, pParam->mb_width, pParam->mb_height,          PreparePredictionsP(pmv, x, y, pParam->mb_width, pParam->mb_height,
1314                                          prevMBs + x + y * pParam->mb_width, Data->rrv);                                          prevMBs + x + y * pParam->mb_width, Data->rrv);
# Line 1112  Line 1322 
1322    
1323          for (i = 1; i < 7; i++) {          for (i = 1; i < 7; i++) {
1324                  if (!(mask = make_mask(pmv, i)) ) continue;                  if (!(mask = make_mask(pmv, i)) ) continue;
1325                  (*CheckCandidate)(pmv[i].x, pmv[i].y, mask, &iDirection, Data);                  CheckCandidate(pmv[i].x, pmv[i].y, mask, &iDirection, Data);
1326                  if (Data->iMinSAD[0] <= threshA) break;                  if (Data->iMinSAD[0] <= threshA) break;
1327          }          }
1328    
1329          if ((Data->iMinSAD[0] <= threshA) ||          if ((Data->iMinSAD[0] <= threshA) ||
1330                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&                          (MVequal(Data->currentMV[0], (prevMBs+x+y*pParam->mb_width)->mvs[0]) &&
1331                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16)))                          (Data->iMinSAD[0] < (prevMBs+x+y*pParam->mb_width)->sad16))) {
1332                  inter4v = 0;                  if (!(GlobalFlags & XVID_MODEDECISION_BITS)) inter4v = 0;       }
1333          else {          else {
1334    
1335                  MainSearchFunc * MainSearchPtr;                  MainSearchFunc * MainSearchPtr;
# Line 1127  Line 1337 
1337                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1338                          else MainSearchPtr = DiamondSearch;                          else MainSearchPtr = DiamondSearch;
1339    
1340                  (*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, iDirection);                  MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
1341    
1342  /* extended search, diamond starting in 0,0 and in prediction.  /* extended search, diamond starting in 0,0 and in prediction.
1343          note that this search is/might be done in halfpel positions,          note that this search is/might be done in halfpel positions,
# Line 1139  Line 1349 
1349                          if (Data->rrv) {                          if (Data->rrv) {
1350                                  startMV.x = RRV_MV_SCALEUP(startMV.x);                                  startMV.x = RRV_MV_SCALEUP(startMV.x);
1351                                  startMV.y = RRV_MV_SCALEUP(startMV.y);                                  startMV.y = RRV_MV_SCALEUP(startMV.y);
1352                          } else                          }
                                 if (!(MotionFlags & PMV_HALFPELREFINE16)) // who's gonna use extsearch and no halfpel?  
                                         startMV.x = EVEN(startMV.x); startMV.y = EVEN(startMV.y);  
1353                          if (!(MVequal(startMV, backupMV))) {                          if (!(MVequal(startMV, backupMV))) {
1354                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;
1355    
1356                                  (*CheckCandidate)(startMV.x, startMV.y, 255, &iDirection, Data);                                  CheckCandidate(startMV.x, startMV.y, 255, &iDirection, Data);
1357                                  (*MainSearchPtr)(startMV.x, startMV.y, Data, 255);                                  MainSearchPtr(startMV.x, startMV.y, Data, 255);
1358                                  if (bSAD < Data->iMinSAD[0]) {                                  if (bSAD < Data->iMinSAD[0]) {
1359                                          Data->currentMV[0] = backupMV;                                          Data->currentMV[0] = backupMV;
1360                                          Data->iMinSAD[0] = bSAD; }                                          Data->iMinSAD[0] = bSAD; }
1361                          }                          }
1362    
1363                          backupMV = Data->currentMV[0];                          backupMV = Data->currentMV[0];
1364                          if (MotionFlags & PMV_HALFPELREFINE16 && !Data->rrv) startMV.x = startMV.y = 1;                          startMV.x = startMV.y = 1;
                         else startMV.x = startMV.y = 0;  
1365                          if (!(MVequal(startMV, backupMV))) {                          if (!(MVequal(startMV, backupMV))) {
1366                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;                                  bSAD = Data->iMinSAD[0]; Data->iMinSAD[0] = MV_MAX_ERROR;
1367    
1368                                  (*CheckCandidate)(startMV.x, startMV.y, 255, &iDirection, Data);                                  CheckCandidate(startMV.x, startMV.y, 255, &iDirection, Data);
1369                                  (*MainSearchPtr)(startMV.x, startMV.y, Data, 255);                                  MainSearchPtr(startMV.x, startMV.y, Data, 255);
1370                                  if (bSAD < Data->iMinSAD[0]) {                                  if (bSAD < Data->iMinSAD[0]) {
1371                                          Data->currentMV[0] = backupMV;                                          Data->currentMV[0] = backupMV;
1372                                          Data->iMinSAD[0] = bSAD; }                                          Data->iMinSAD[0] = bSAD; }
# Line 1167  Line 1374 
1374                  }                  }
1375          }          }
1376    
1377          if (MotionFlags & PMV_HALFPELREFINE16) SubpelRefine(Data);          if (MotionFlags & PMV_HALFPELREFINE16)
1378                    if ((!(MotionFlags & HALFPELREFINE16_BITS)) || Data->iMinSAD[0] < 200*(int)iQuant)
1379                            SubpelRefine(Data);
1380    
1381          for(i = 0; i < 5; i++) {          for(i = 0; i < 5; i++) {
1382                  Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // initialize qpel vectors                  Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // initialize qpel vectors
1383                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;                  Data->currentQMV[i].y = 2 * Data->currentMV[i].y;
1384          }          }
1385    
1386          if (Data->qpel && MotionFlags & PMV_QUARTERPELREFINE16) {          if (MotionFlags & PMV_QUARTERPELREFINE16) {
1387                  Data->qpel_precision = 1;  
1388                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,                  get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
1389                                  pParam->width, pParam->height, Data->iFcode, 1, 0);                                  pParam->width, pParam->height, Data->iFcode, 1, 0);
1390    
1391                    if ((!(MotionFlags & QUARTERPELREFINE16_BITS)) || (Data->iMinSAD[0] < 200*(int)iQuant)) {
1392                            Data->qpel_precision = 1;
1393                  SubpelRefine(Data);                  SubpelRefine(Data);
1394          }          }
1395            }
1396    
1397            if ((!(GlobalFlags & XVID_MODEDECISION_BITS)) && (Data->iMinSAD[0] < (int32_t)iQuant * 30)) inter4v = 0;
1398    
1399            if (inter4v && (!(GlobalFlags & XVID_MODEDECISION_BITS) ||
1400                            (!(MotionFlags & QUARTERPELREFINE8_BITS)) || (!(MotionFlags & HALFPELREFINE8_BITS)) ||
1401                            ((!(MotionFlags & EXTSEARCH_BITS)) && (!(MotionFlags&PMV_EXTSEARCH8)) ))) {
1402                    // if decision is BITS-based and all refinement steps will be done in BITS domain, there is no reason to call this loop
1403    
         if (Data->iMinSAD[0] < (int32_t)iQuant * 30) inter4v = 0;  
         if (inter4v) {  
1404                  SearchData Data8;                  SearchData Data8;
1405                  memcpy(&Data8, Data, sizeof(SearchData)); //quick copy of common data                  memcpy(&Data8, Data, sizeof(SearchData)); //quick copy of common data
1406    
# Line 1192  Line 1409 
1409                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8);                  Search8(Data, 2*x, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 2, &Data8);
1410                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8);                  Search8(Data, 2*x + 1, 2*y + 1, MotionFlags, pParam, pMB, pMBs, 3, &Data8);
1411    
1412                  if (Data->chroma) {                  if ((Data->chroma) && (!(GlobalFlags & XVID_MODEDECISION_BITS))) {
1413                            // chroma is only used for comparsion to INTER. if the comparsion will be done in BITS domain, there is no reason to compute it
1414                          int sumx = 0, sumy = 0;                          int sumx = 0, sumy = 0;
1415                          const int div = 1 + Data->qpel;                          const int div = 1 + Data->qpel;
1416                          const VECTOR * const mv = Data->qpel ? pMB->qmvs : pMB->mvs;                          const VECTOR * const mv = Data->qpel ? pMB->qmvs : pMB->mvs;
# Line 1207  Line 1425 
1425                  }                  }
1426          }          }
1427    
1428            inter4v = ModeDecision(iQuant, Data, inter4v, pMB, pMBs, x, y, pParam, MotionFlags, GlobalFlags);
1429    
1430          if (Data->rrv) {          if (Data->rrv) {
1431                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);                          Data->currentMV[0].x = RRV_MV_SCALEDOWN(Data->currentMV[0].x);
1432                          Data->currentMV[0].y = RRV_MV_SCALEDOWN(Data->currentMV[0].y);                          Data->currentMV[0].y = RRV_MV_SCALEDOWN(Data->currentMV[0].y);
1433          }          }
1434    
1435          if (!(inter4v) ||          if (inter4v == MODE_INTER) {
                 (Data->iMinSAD[0] < Data->iMinSAD[1] + Data->iMinSAD[2] +  
                         Data->iMinSAD[3] + Data->iMinSAD[4] + IMV16X16 * (int32_t)iQuant )) {  
 // INTER MODE  
1436                  pMB->mode = MODE_INTER;                  pMB->mode = MODE_INTER;
1437                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = Data->currentMV[0];                  pMB->mvs[0] = pMB->mvs[1] = pMB->mvs[2] = pMB->mvs[3] = Data->currentMV[0];
1438                  pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = Data->iMinSAD[0];                  pMB->sad16 = pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = Data->iMinSAD[0];
# Line 1229  Line 1446 
1446                          pMB->pmvs[0].x = Data->currentMV[0].x - Data->predMV.x;                          pMB->pmvs[0].x = Data->currentMV[0].x - Data->predMV.x;
1447                          pMB->pmvs[0].y = Data->currentMV[0].y - Data->predMV.y;                          pMB->pmvs[0].y = Data->currentMV[0].y - Data->predMV.y;
1448                  }                  }
1449          } else {  
1450  // INTER4V MODE; all other things are already set in Search8          } else if (inter4v == MODE_INTER4V) {
1451                  pMB->mode = MODE_INTER4V;                  pMB->mode = MODE_INTER4V;
1452                  pMB->sad16 = Data->iMinSAD[1] + Data->iMinSAD[2] +                  pMB->sad16 = Data->iMinSAD[0];
1453                          Data->iMinSAD[3] + Data->iMinSAD[4] + IMV16X16 * iQuant;          } else { // INTRA mode
1454                    SkipMacroblockP(pMB, 0); // not skip, but similar enough
1455                    pMB->mode = MODE_INTRA;
1456          }          }
1457    
1458  }  }
1459    
1460  static void  static void
# Line 1281  Line 1501 
1501                  if (!Data->rrv) CheckCandidate = CheckCandidate8;                  if (!Data->rrv) CheckCandidate = CheckCandidate8;
1502                  else CheckCandidate = CheckCandidate16no4v;                  else CheckCandidate = CheckCandidate16no4v;
1503    
1504                  if (MotionFlags & PMV_EXTSEARCH8) {                  if (MotionFlags & PMV_EXTSEARCH8 && (!(MotionFlags & EXTSEARCH_BITS))) {
1505                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD                          int32_t temp_sad = *(Data->iMinSAD); // store current MinSAD
1506    
1507                          MainSearchFunc *MainSearchPtr;                          MainSearchFunc *MainSearchPtr;
# Line 1289  Line 1509 
1509                                  else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch;                                  else if (MotionFlags & PMV_ADVANCEDDIAMOND8) MainSearchPtr = AdvDiamondSearch;
1510                                          else MainSearchPtr = DiamondSearch;                                          else MainSearchPtr = DiamondSearch;
1511    
1512                          (*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, 255);                          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, 255);
1513    
1514                          if(*(Data->iMinSAD) < temp_sad) {                          if(*(Data->iMinSAD) < temp_sad) {
1515                                          Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector                                          Data->currentQMV->x = 2 * Data->currentMV->x; // update our qpel vector
# Line 1436  Line 1656 
1656          else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;          else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1657                  else MainSearchPtr = DiamondSearch;                  else MainSearchPtr = DiamondSearch;
1658    
1659          (*MainSearchPtr)(Data->currentMV->x, Data->currentMV->y, Data, iDirection);          MainSearchPtr(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
1660    
1661          SubpelRefine(Data);          SubpelRefine(Data);
1662    
# Line 1590  Line 1810 
1810    
1811          CheckCandidate = b_mb->mode == MODE_INTER4V ? CheckCandidateDirect : CheckCandidateDirectno4v;          CheckCandidate = b_mb->mode == MODE_INTER4V ? CheckCandidateDirect : CheckCandidateDirectno4v;
1812    
1813          (*CheckCandidate)(0, 0, 255, &k, Data);          CheckCandidate(0, 0, 255, &k, Data);
1814    
1815  // initial (fast) skip decision  // initial (fast) skip decision
1816          if (*Data->iMinSAD < pMB->quant * INITIAL_SKIP_THRESH * (2 + Data->chroma?1:0)) {          if (*Data->iMinSAD < pMB->quant * INITIAL_SKIP_THRESH * (2 + Data->chroma?1:0)) {
# Line 1604  Line 1824 
1824                  }                  }
1825          }          }
1826    
1827            *Data->iMinSAD += Data->lambda16;
1828          skip_sad = *Data->iMinSAD;          skip_sad = *Data->iMinSAD;
1829    
1830  //      DIRECT MODE DELTA VECTOR SEARCH.  //      DIRECT MODE DELTA VECTOR SEARCH.
# Line 1613  Line 1834 
1834                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;                  else if (MotionFlags & PMV_ADVANCEDDIAMOND16) MainSearchPtr = AdvDiamondSearch;
1835                          else MainSearchPtr = DiamondSearch;                          else MainSearchPtr = DiamondSearch;
1836    
1837          (*MainSearchPtr)(0, 0, Data, 255);          MainSearchPtr(0, 0, Data, 255);
1838    
1839          SubpelRefine(Data);          SubpelRefine(Data);
1840    
# Line 1930  Line 2151 
2151    
2152          int i, mask;          int i, mask;
2153          VECTOR pmv[3];          VECTOR pmv[3];
2154          MACROBLOCK * pMB = &pMBs[x + y * pParam->mb_width];          MACROBLOCK * const pMB = &pMBs[x + y * pParam->mb_width];
2155    
2156          for (i = 0; i < 5; i++) Data->iMinSAD[i] = MV_MAX_ERROR;          for (i = 0; i < 5; i++) Data->iMinSAD[i] = MV_MAX_ERROR;
2157    
# Line 1944  Line 2165 
2165                          else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median                          else Data->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, 0); //else median
2166    
2167          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,          get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
2168                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel, 0, Data->rrv);                                  pParam->width, pParam->height, Data->iFcode - pParam->m_quarterpel, 0, 0);
2169    
2170          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;          Data->Cur = pCur + (x + y * pParam->edged_width) * 16;
2171          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;          Data->Ref = pRef + (x + y * pParam->edged_width) * 16;
# Line 1956  Line 2177 
2177          pmv[0].x = pmv[0].y = 0;          pmv[0].x = pmv[0].y = 0;
2178    
2179          CheckCandidate32I(0, 0, 255, &i, Data);          CheckCandidate32I(0, 0, 255, &i, Data);
2180            Data->iMinSAD[1] -= 50;
2181            Data->iMinSAD[2] -= 50;
2182            Data->iMinSAD[3] -= 50;
2183            Data->iMinSAD[4] -= 50;
2184    
2185          if (*Data->iMinSAD > 4 * MAX_SAD00_FOR_SKIP * 4) {          if (*Data->iMinSAD > 4 * MAX_SAD00_FOR_SKIP) {
2186    
2187                  if (!(mask = make_mask(pmv, 1)))                  if (!(mask = make_mask(pmv, 1)))
2188                          CheckCandidate32I(pmv[1].x, pmv[1].y, mask, &i, Data);                          CheckCandidate32I(pmv[1].x, pmv[1].y, mask, &i, Data);
2189                  if (!(mask = make_mask(pmv, 2)))                  if (!(mask = make_mask(pmv, 2)))
2190                          CheckCandidate32I(pmv[2].x, pmv[2].y, mask, &i, Data);                          CheckCandidate32I(pmv[2].x, pmv[2].y, mask, &i, Data);
2191    
2192                  if (*Data->iMinSAD > 4 * MAX_SAD00_FOR_SKIP * 4) // diamond only if needed                  if (*Data->iMinSAD > 4 * MAX_SAD00_FOR_SKIP) // diamond only if needed
2193                          DiamondSearch(Data->currentMV->x, Data->currentMV->y, Data, i);                          DiamondSearch(Data->currentMV->x, Data->currentMV->y, Data, i);
2194            }
2195    
2196                  for (i = 0; i < 4; i++) {                  for (i = 0; i < 4; i++) {
2197                          MACROBLOCK * MB = &pMBs[x + (i&1) + (y+(i>>1)) * pParam->mb_width];                          MACROBLOCK * MB = &pMBs[x + (i&1) + (y+(i>>1)) * pParam->mb_width];
# Line 1974  Line 2200 
2200                          MB->sad16 = Data->iMinSAD[i+1];                          MB->sad16 = Data->iMinSAD[i+1];
2201                  }                  }
2202          }          }
 }  
2203    
2204  #define INTRA_BIAS              2500  #define INTRA_THRESH    2400
2205  #define INTRA_THRESH    1500  #define INTER_THRESH    1100
 #define INTER_THRESH    1400  
2206    
2207  int  int
2208  MEanalysis(     const IMAGE * const pRef,  MEanalysis(     const IMAGE * const pRef,
2209                          FRAMEINFO * const Current,                          const FRAMEINFO * const Current,
2210                          MBParam * const pParam,                          const MBParam * const pParam,
2211                          int maxIntra, //maximum number if non-I frames                          const int maxIntra, //maximum number if non-I frames
2212                          int intraCount, //number of non-I frames after last I frame; 0 if we force P/B frame                          const int intraCount, //number of non-I frames after last I frame; 0 if we force P/B frame
2213                          int bCount) // number of B frames in a row                          const int bCount,  // number of B frames in a row
2214                            const int b_thresh)
2215  {  {
2216          uint32_t x, y, intra = 0;          uint32_t x, y, intra = 0;
2217          int sSAD = 0;          int sSAD = 0;
2218          MACROBLOCK * const pMBs = Current->mbs;          MACROBLOCK * const pMBs = Current->mbs;
2219          const IMAGE * const pCurrent = &Current->image;          const IMAGE * const pCurrent = &Current->image;
2220          int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH;          int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + 10*b_thresh;
2221            int s = 0, blocks = 0;
2222    
2223          int32_t iMinSAD[5], temp[5];          int32_t iMinSAD[5], temp[5];
2224          VECTOR currentMV[5];          VECTOR currentMV[5];
# Line 2001  Line 2227 
2227          Data.currentMV = currentMV;          Data.currentMV = currentMV;
2228          Data.iMinSAD = iMinSAD;          Data.iMinSAD = iMinSAD;
2229          Data.iFcode = Current->fcode;          Data.iFcode = Current->fcode;
         Data.rrv = Current->global_flags & XVID_REDUCED;  
2230          Data.temp = temp;          Data.temp = temp;
2231          CheckCandidate = CheckCandidate32I;          CheckCandidate = CheckCandidate32I;
2232    
2233          if (intraCount != 0 && intraCount < 10) // we're right after an I frame          if (intraCount != 0 && intraCount < 10) // we're right after an I frame
2234                  IntraThresh += 4 * (intraCount - 10) * (intraCount - 10);                  IntraThresh += 8 * (intraCount - 10) * (intraCount - 10);
2235          else          else
2236                  if ( 5*(maxIntra - intraCount) < maxIntra) // we're close to maximum. 2 sec when max is 10 sec                  if ( 5*(maxIntra - intraCount) < maxIntra) // we're close to maximum. 2 sec when max is 10 sec
2237                          IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra;                          IntraThresh -= (IntraThresh * (maxIntra - 5*(maxIntra - intraCount)))/maxIntra;
2238    
2239          InterThresh += 400 * (1 - bCount);          InterThresh -= (350 - 8*b_thresh) * bCount;
2240          if (InterThresh < 300) InterThresh = 300;          if (InterThresh < 300 + 5*b_thresh) InterThresh = 300 + 5*b_thresh;
2241    
2242          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
2243    
2244          for (y = 1; y < pParam->mb_height-1; y += 2) {          for (y = 1; y < pParam->mb_height-1; y += 2) {
2245                  for (x = 1; x < pParam->mb_width-1; x += 2) {                  for (x = 1; x < pParam->mb_width-1; x += 2) {
2246                          int i;                          int i;
2247                            blocks += 4;
2248    
2249                          if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV;                          if (bCount == 0) pMBs[x + y * pParam->mb_width].mvs[0] = zeroMV;
2250                            else { //extrapolation of the vector found for last frame
2251                                    pMBs[x + y * pParam->mb_width].mvs[0].x =
2252                                            (pMBs[x + y * pParam->mb_width].mvs[0].x * (bCount+1) ) / bCount;
2253                                    pMBs[x + y * pParam->mb_width].mvs[0].y =
2254                                            (pMBs[x + y * pParam->mb_width].mvs[0].y * (bCount+1) ) / bCount;
2255                            }
2256    
2257                          MEanalyzeMB(pRef->y, pCurrent->y, x, y, pParam, pMBs, &Data);                          MEanalyzeMB(pRef->y, pCurrent->y, x, y, pParam, pMBs, &Data);
2258    
# Line 2032  Line 2264 
2264                                                                          pParam->edged_width);                                                                          pParam->edged_width);
2265                                          if (dev + IntraThresh < pMB->sad16) {                                          if (dev + IntraThresh < pMB->sad16) {
2266                                                  pMB->mode = MODE_INTRA;                                                  pMB->mode = MODE_INTRA;
2267                                                  if (++intra > (pParam->mb_height-2)*(pParam->mb_width-2)/2) return I_VOP;                                                  if (++intra > ((pParam->mb_height-2)*(pParam->mb_width-2))/2) return I_VOP;
2268                                          }                                          }
2269                                  }                                  }
2270                                    if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0) s++;
2271    
2272                                  sSAD += pMB->sad16;                                  sSAD += pMB->sad16;
2273                          }                          }
2274                  }                  }
2275          }          }
2276          sSAD /= (pParam->mb_height-2)*(pParam->mb_width-2);  
2277  //      if (sSAD > IntraThresh + INTRA_BIAS) return I_VOP;          sSAD /= blocks;
2278            s = (10*s) / blocks;
2279    
2280            if (s > 5) sSAD += (s - 4) * (180 - 2*b_thresh); //static block - looks bad when in bframe...
2281    
2282          if (sSAD > InterThresh ) return P_VOP;          if (sSAD > InterThresh ) return P_VOP;
2283          emms();          emms();
2284          return B_VOP;          return B_VOP;
   
2285  }  }
2286    
2287    
# Line 2076  Line 2313 
2313          double meanx,meany;          double meanx,meany;
2314          int num,oldnum;          int num,oldnum;
2315    
2316          if (!MBmask) { fprintf(stderr,"Mem error\n"); return gmc;}          if (!MBmask) { fprintf(stderr,"Mem error\n");
2317                                   gmc.duv[0].x= gmc.duv[0].y =
2318                                                    gmc.duv[1].x= gmc.duv[1].y =
2319                                                    gmc.duv[2].x= gmc.duv[2].y = 0;
2320                                            return gmc; }
2321    
2322  // filter mask of all blocks  // filter mask of all blocks
2323    
2324          for (my = 1; my < MBh-1; my++)          for (my = 1; my < (uint32_t)MBh-1; my++)
2325          for (mx = 1; mx < MBw-1; mx++)          for (mx = 1; mx < (uint32_t)MBw-1; mx++)
2326          {          {
2327                  const int mbnum = mx + my * MBw;                  const int mbnum = mx + my * MBw;
2328                  const MACROBLOCK *pMB = &pMBs[mbnum];                  const MACROBLOCK *pMB = &pMBs[mbnum];
# Line 2097  Line 2338 
2338                          MBmask[mbnum]=1;                          MBmask[mbnum]=1;
2339          }          }
2340    
2341          for (my = 1; my < MBh-1; my++)          for (my = 1; my < (uint32_t)MBh-1; my++)
2342          for (mx = 1; mx < MBw-1; mx++)          for (mx = 1; mx < (uint32_t)MBw-1; mx++)
2343          {          {
2344                  const uint8_t *const pCur = current->image.y + 16*my*pParam->edged_width + 16*mx;                  const uint8_t *const pCur = current->image.y + 16*my*pParam->edged_width + 16*mx;
2345    
# Line 2106  Line 2347 
2347                  if (!MBmask[mbnum])                  if (!MBmask[mbnum])
2348                          continue;                          continue;
2349    
2350                  if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= grad )                  if (sad16 ( pCur, pCur+1 , pParam->edged_width, 65536) <= (uint32_t)grad )
2351                          MBmask[mbnum] = 0;                          MBmask[mbnum] = 0;
2352                  if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= grad )                  if (sad16 ( pCur, pCur+pParam->edged_width, pParam->edged_width, 65536) <= (uint32_t)grad )
2353                          MBmask[mbnum] = 0;                          MBmask[mbnum] = 0;
2354    
2355          }          }
# Line 2119  Line 2360 
2360    
2361          a = b = c = n = 0;          a = b = c = n = 0;
2362          DtimesF[0] = DtimesF[1] = DtimesF[2] = DtimesF[3] = 0.;          DtimesF[0] = DtimesF[1] = DtimesF[2] = DtimesF[3] = 0.;
2363          for (my = 0; my < MBh; my++)          for (my = 0; my < (uint32_t)MBh; my++)
2364                  for (mx = 0; mx < MBw; mx++)                  for (mx = 0; mx < (uint32_t)MBw; mx++)
2365                  {                  {
2366                          const int mbnum = mx + my * MBw;                          const int mbnum = mx + my * MBw;
2367                          const MACROBLOCK *pMB = &pMBs[mbnum];                          const MACROBLOCK *pMB = &pMBs[mbnum];
# Line 2157  Line 2398 
2398    
2399          meanx = meany = 0.;          meanx = meany = 0.;
2400          oldnum = 0;          oldnum = 0;
2401          for (my = 0; my < MBh; my++)          for (my = 0; my < (uint32_t)MBh; my++)
2402                  for (mx = 0; mx < MBw; mx++)                  for (mx = 0; mx < (uint32_t)MBw; mx++)
2403                  {                  {
2404                          const int mbnum = mx + my * MBw;                          const int mbnum = mx + my * MBw;
2405                          const MACROBLOCK *pMB = &pMBs[mbnum];                          const MACROBLOCK *pMB = &pMBs[mbnum];
# Line 2186  Line 2427 
2427          fprintf(stderr,"meanx = %8.5f  meany = %8.5f   %d\n",meanx,meany, oldnum);          fprintf(stderr,"meanx = %8.5f  meany = %8.5f   %d\n",meanx,meany, oldnum);
2428  */  */
2429          num = 0;          num = 0;
2430          for (my = 0; my < MBh; my++)          for (my = 0; my < (uint32_t)MBh; my++)
2431                  for (mx = 0; mx < MBw; mx++)                  for (mx = 0; mx < (uint32_t)MBw; mx++)
2432                  {                  {
2433                          const int mbnum = mx + my * MBw;                          const int mbnum = mx + my * MBw;
2434                          const MACROBLOCK *pMB = &pMBs[mbnum];                          const MACROBLOCK *pMB = &pMBs[mbnum];
# Line 2225  Line 2466 
2466    
2467          return gmc;          return gmc;
2468  }  }
2469    
2470    // functions which perform BITS-based search/bitcount
2471    
2472    static int
2473    CountMBBitsInter(SearchData * const Data,
2474                                    const MACROBLOCK * const pMBs, const int x, const int y,
2475                                    const MBParam * const pParam,
2476                                    const uint32_t MotionFlags)
2477    {
2478            int i, iDirection;
2479            int32_t bsad[5];
2480    
2481            CheckCandidate = CheckCandidateBits16;
2482    
2483            if (Data->qpel) {
2484                    for(i = 0; i < 5; i++) {
2485                            Data->currentMV[i].x = Data->currentQMV[i].x/2;
2486                            Data->currentMV[i].y = Data->currentQMV[i].y/2;
2487                    }
2488                    Data->qpel_precision = 1;
2489                    CheckCandidateBits16(Data->currentQMV[0].x, Data->currentQMV[0].y, 255, &iDirection, Data);
2490    
2491                    //checking if this vector is perfect. if it is, we stop.
2492                    if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0)
2493                            return 0; //quick stop
2494    
2495                    if (MotionFlags & (HALFPELREFINE16_BITS | EXTSEARCH_BITS)) { //we have to prepare for halfpixel-precision search
2496                            for(i = 0; i < 5; i++) bsad[i] = Data->iMinSAD[i];
2497                            get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
2498                                                    pParam->width, pParam->height, Data->iFcode - Data->qpel, 0, Data->rrv);
2499                            Data->qpel_precision = 0;
2500                            if (Data->currentQMV->x & 1 || Data->currentQMV->y & 1)
2501                                    CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data);
2502                    }
2503    
2504            } else { // not qpel
2505    
2506                    CheckCandidateBits16(Data->currentMV[0].x, Data->currentMV[0].y, 255, &iDirection, Data);
2507                    //checking if this vector is perfect. if it is, we stop.
2508                    if (Data->temp[0] == 0 && Data->temp[1] == 0 && Data->temp[2] == 0 && Data->temp[3] == 0) {
2509                            return 0; //inter
2510                    }
2511            }
2512    
2513            if (MotionFlags&EXTSEARCH_BITS) SquareSearch(Data->currentMV->x, Data->currentMV->y, Data, iDirection);
2514    
2515            if (MotionFlags&HALFPELREFINE16_BITS) SubpelRefine(Data);
2516    
2517            if (Data->qpel) {
2518                    if (MotionFlags&(EXTSEARCH_BITS | HALFPELREFINE16_BITS)) { // there was halfpel-precision search
2519                            for(i = 0; i < 5; i++) if (bsad[i] > Data->iMinSAD[i]) {
2520                                    Data->currentQMV[i].x = 2 * Data->currentMV[i].x; // we have found a better match
2521                                    Data->currentQMV[i].y = 2 * Data->currentMV[i].y;
2522                            }
2523    
2524                            // preparing for qpel-precision search
2525                            Data->qpel_precision = 1;
2526                            get_range(&Data->min_dx, &Data->max_dx, &Data->min_dy, &Data->max_dy, x, y, 16,
2527                                            pParam->width, pParam->height, Data->iFcode, 1, 0);
2528                    }
2529                    if (MotionFlags&QUARTERPELREFINE16_BITS) SubpelRefine(Data);
2530            }
2531    
2532            if (MotionFlags&CHECKPREDICTION_BITS) { //let's check vector equal to prediction
2533                    VECTOR * v = Data->qpel ? Data->currentQMV : Data->currentMV;
2534                    if (!(Data->predMV.x == v->x && Data->predMV.y == v->y))
2535                            CheckCandidateBits16(Data->predMV.x, Data->predMV.y, 255, &iDirection, Data);
2536            }
2537            return Data->iMinSAD[0];
2538    }
2539    
2540    
2541    static int
2542    CountMBBitsInter4v(const SearchData * const Data,
2543                                            MACROBLOCK * const pMB, const MACROBLOCK * const pMBs,
2544                                            const int x, const int y,
2545                                            const MBParam * const pParam, const uint32_t MotionFlags,
2546                                            const VECTOR * const backup)
2547    {
2548    
2549            int cbp = 0, bits = 0, t = 0, i, iDirection;
2550            SearchData Data2, *Data8 = &Data2;
2551            int sumx = 0, sumy = 0;
2552            int16_t *in = Data->dctSpace, *coeff = Data->dctSpace + 64;
2553    
2554            memcpy(Data8, Data, sizeof(SearchData));
2555            CheckCandidate = CheckCandidateBits8;
2556    
2557            for (i = 0; i < 4; i++) {
2558                    Data8->iMinSAD = Data->iMinSAD + i + 1;
2559                    Data8->currentMV = Data->currentMV + i + 1;
2560                    Data8->currentQMV = Data->currentQMV + i + 1;
2561                    Data8->Cur = Data->Cur + 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2562                    Data8->Ref = Data->Ref + 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2563                    Data8->RefH = Data->RefH + 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2564                    Data8->RefV = Data->RefV + 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2565                    Data8->RefHV = Data->RefHV + 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2566    
2567                    if(Data->qpel) {
2568                            Data8->predMV = get_qpmv2(pMBs, pParam->mb_width, 0, x, y, i);
2569                            if (i != 0)     t = d_mv_bits(  Data8->currentQMV->x, Data8->currentQMV->y,
2570                                                                                    Data8->predMV, Data8->iFcode, 0, 0);
2571                    } else {
2572                            Data8->predMV = get_pmv2(pMBs, pParam->mb_width, 0, x, y, i);
2573                            if (i != 0)     t = d_mv_bits(  Data8->currentMV->x, Data8->currentMV->y,
2574                                                                                    Data8->predMV, Data8->iFcode, 0, 0);
2575                    }
2576    
2577                    get_range(&Data8->min_dx, &Data8->max_dx, &Data8->min_dy, &Data8->max_dy, 2*x + (i&1), 2*y + (i>>1), 8,
2578                                            pParam->width, pParam->height, Data8->iFcode, Data8->qpel, 0);
2579    
2580                    *Data8->iMinSAD += t;
2581    
2582                    Data8->qpel_precision = Data8->qpel;
2583                    // checking the vector which has been found by SAD-based 8x8 search (if it's different than the one found so far)
2584                    if (Data8->qpel) {
2585                            if (!(Data8->currentQMV->x == backup[i+1].x && Data8->currentQMV->y == backup[i+1].y))
2586                                    CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8);
2587                    } else {
2588                            if (!(Data8->currentMV->x == backup[i+1].x && Data8->currentMV->y == backup[i+1].y))
2589                                    CheckCandidateBits8(backup[i+1].x, backup[i+1].y, 255, &iDirection, Data8);
2590                    }
2591    
2592                    if (Data8->qpel) {
2593                            if (MotionFlags&HALFPELREFINE8_BITS || (MotionFlags&PMV_EXTSEARCH8 && MotionFlags&EXTSEARCH_BITS)) { // halfpixel motion search follows
2594                                    int32_t s = *Data8->iMinSAD;
2595                                    Data8->currentMV->x = Data8->currentQMV->x/2;
2596                                    Data8->currentMV->y = Data8->currentQMV->y/2;
2597                                    Data8->qpel_precision = 0;
2598                                    get_range(&Data8->min_dx, &Data8->max_dx, &Data8->min_dy, &Data8->max_dy, 2*x + (i&1), 2*y + (i>>1), 8,
2599                                                            pParam->width, pParam->height, Data8->iFcode - 1, 0, 0);
2600    
2601                                    if (Data8->currentQMV->x & 1 || Data8->currentQMV->y & 1)
2602                                            CheckCandidateBits8(Data8->currentMV->x, Data8->currentMV->y, 255, &iDirection, Data8);
2603    
2604                                    if (MotionFlags & PMV_EXTSEARCH8 && MotionFlags & EXTSEARCH_BITS)
2605                                            SquareSearch(Data8->currentMV->x, Data8->currentMV->x, Data8, 255);
2606    
2607                                    if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8);
2608    
2609                                    if(s > *Data8->iMinSAD) { //we have found a better match
2610                                            Data8->currentQMV->x = 2*Data8->currentMV->x;
2611                                            Data8->currentQMV->y = 2*Data8->currentMV->y;
2612                                    }
2613    
2614                                    Data8->qpel_precision = 1;
2615                                    get_range(&Data8->min_dx, &Data8->max_dx, &Data8->min_dy, &Data8->max_dy, 2*x + (i&1), 2*y + (i>>1), 8,
2616                                                            pParam->width, pParam->height, Data8->iFcode, 1, 0);
2617    
2618                            }
2619                            if (MotionFlags & QUARTERPELREFINE8_BITS) SubpelRefine(Data8);
2620    
2621                    } else // not qpel
2622                            if (MotionFlags & HALFPELREFINE8_BITS) SubpelRefine(Data8); //halfpel mode, halfpel refinement
2623    
2624                    //checking vector equal to predicion
2625                    if (i != 0 && MotionFlags & CHECKPREDICTION_BITS) {
2626                            const VECTOR * v = Data->qpel ? Data8->currentQMV : Data8->currentMV;
2627                            if (!(Data8->predMV.x == v->x && Data8->predMV.y == v->y))
2628                                    CheckCandidateBits8(Data8->predMV.x, Data8->predMV.y, 255, &iDirection, Data8);
2629                    }
2630    
2631                    bits += *Data8->iMinSAD;
2632                    if (bits >= Data->iMinSAD[0]) break; // no chances for INTER4V
2633    
2634                    // MB structures for INTER4V mode; we have to set them here, we don't have predictor anywhere else
2635                    if(Data->qpel) {
2636                            pMB->pmvs[i].x = Data8->currentQMV->x - Data8->predMV.x;
2637                            pMB->pmvs[i].y = Data8->currentQMV->y - Data8->predMV.y;
2638                            pMB->qmvs[i] = *Data8->currentQMV;
2639                            sumx += Data8->currentQMV->x/2;
2640                            sumy += Data8->currentQMV->y/2;
2641                    } else {
2642                            pMB->pmvs[i].x = Data8->currentMV->x - Data8->predMV.x;
2643                            pMB->pmvs[i].y = Data8->currentMV->y - Data8->predMV.y;
2644                            sumx += Data8->currentMV->x;
2645                            sumy += Data8->currentMV->y;
2646                    }
2647                    pMB->mvs[i] = *Data8->currentMV;
2648                    pMB->sad8[i] = 4 * *Data8->iMinSAD;
2649                    if (Data8->temp[0]) cbp |= 1 << (5 - i);
2650            }
2651    
2652            if (bits < *Data->iMinSAD) { // there is still a chance for inter4v mode. let's check chroma
2653                    const uint8_t * ptr;
2654                    sumx = (sumx >> 3) + roundtab_76[sumx & 0xf];
2655                    sumy = (sumy >> 3) + roundtab_76[sumy & 0xf];
2656    
2657                    //chroma U
2658                    ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefCU, 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding);
2659                    transfer_8to16subro(in, Data->CurU, ptr, Data->iEdgedWidth/2);
2660                    fdct(in);
2661                    if (Data->lambda8 == 0) i = quant_inter(coeff, in, Data->lambda16);
2662                    else i = quant4_inter(coeff, in, Data->lambda16);
2663                    if (i > 0) {
2664                            bits += CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
2665                            cbp |= 1 << (5 - 4);
2666                    }
2667    
2668                    if (bits < *Data->iMinSAD) { // still possible
2669                            //chroma V
2670                            ptr = interpolate8x8_switch2(Data->RefQ + 64, Data->RefCV, 0, 0, sumx, sumy, Data->iEdgedWidth/2, Data->rounding);
2671                            transfer_8to16subro(in, Data->CurV, ptr, Data->iEdgedWidth/2);
2672                            fdct(in);
2673                            if (Data->lambda8 == 0) i = quant_inter(coeff, in, Data->lambda16);
2674                            else i = quant4_inter(coeff, in, Data->lambda16);
2675                            if (i > 0) {
2676                                    bits += CodeCoeffInter_CalcBits(coeff, scan_tables[0]);
2677                                    cbp |= 1 << (5 - 5);
2678                            }
2679                            bits += xvid_cbpy_tab[15-(cbp>>2)].len;
2680                            bits += mcbpc_inter_tab[(MODE_INTER4V & 7) | ((cbp & 3) << 3)].len;
2681                    }
2682            }
2683    
2684            return bits;
2685    }
2686    
2687    
2688    static int
2689    CountMBBitsIntra(const SearchData * const Data)
2690    {
2691            int bits = 1; //this one is ac/dc prediction flag. always 1.
2692            int cbp = 0, i, t, dc = 0, b_dc = 1024;
2693            const uint32_t iQuant = Data->lambda16;
2694            int16_t *in = Data->dctSpace, * coeff = Data->dctSpace + 64;
2695    
2696            for(i = 0; i < 4; i++) {
2697                    uint32_t iDcScaler = get_dc_scaler(iQuant, 1);
2698    
2699                    int s = 8*((i&1) + (i>>1)*Data->iEdgedWidth);
2700                    transfer_8to16copy(in, Data->Cur + s, Data->iEdgedWidth);
2701                    fdct(in);
2702                    b_dc = dc;
2703                    dc = in[0];
2704                    in[0] -= b_dc;
2705                    if (Data->lambda8 == 0) quant_intra_c(coeff, in, iQuant, iDcScaler);
2706                    else quant4_intra_c(coeff, in, iQuant, iDcScaler);
2707    
2708                    b_dc = dc;
2709                    dc = coeff[0];
2710                    if (i != 0) coeff[0] -= b_dc;
2711    
2712                    bits += t = CodeCoeffIntra_CalcBits(coeff, scan_tables[0]) + dcy_tab[coeff[0] + 255].len;;
2713                    Data->temp[i] = t;
2714                    if (t != 0)  cbp |= 1 << (5 - i);
2715                    if (bits >= Data->iMinSAD[0]) break;
2716            }
2717    
2718            if (bits < Data->iMinSAD[0]) { // INTRA still looks good, let's add chroma
2719                    uint32_t iDcScaler = get_dc_scaler(iQuant, 0);
2720                    //chroma U
2721                    transfer_8to16copy(in, Data->CurU, Data->iEdgedWidth/2);
2722                    fdct(in);
2723                    in[0] -= 1024;
2724                    if (Data->lambda8 == 0) quant_intra(coeff, in, iQuant, iDcScaler);
2725                    else quant4_intra(coeff, in, iQuant, iDcScaler);
2726    
2727                    bits += t = CodeCoeffIntra_CalcBits(coeff, scan_tables[0]) + dcc_tab[coeff[0] + 255].len;
2728                    if (t != 0) cbp |= 1 << (5 - 4);
2729    
2730                    if (bits < Data->iMinSAD[0]) {
2731                            iDcScaler = get_dc_scaler(iQuant, 1);
2732                            //chroma V
2733                            transfer_8to16copy(in, Data->CurV, Data->iEdgedWidth/2);
2734                            fdct(in);
2735                            in[0] -= 1024;
2736                            if (Data->lambda8 == 0) quant_intra(coeff, in, iQuant, iDcScaler);
2737                            else quant4_intra(coeff, in, iQuant, iDcScaler);
2738    
2739                            bits += t = CodeCoeffIntra_CalcBits(coeff, scan_tables[0]) + dcc_tab[coeff[0] + 255].len;
2740                            if (t != 0) cbp |= 1 << (5 - 5);
2741    
2742                            bits += xvid_cbpy_tab[cbp>>2].len;
2743                            bits += mcbpc_inter_tab[(MODE_INTRA & 7) | ((cbp & 3) << 3)].len;
2744                    }
2745            }
2746            return bits;
2747    }

Legend:
Removed from v.1.44.2.50  
changed lines
  Added in v.1.61

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