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

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

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

revision 1.1.2.5, Wed Nov 19 12:24:25 2003 UTC revision 1.1.2.7, Fri Dec 5 12:27:48 2003 UTC
# Line 37  Line 37 
37  #define INTER_THRESH    40  #define INTER_THRESH    40
38  #define INTRA_THRESH2   90  #define INTRA_THRESH2   90
39    
40    /* when we are in 1/I_SENS_TH before forced keyframe, we start to decrese i-frame threshold */
41    #define I_SENS_TH               3
42    
43    /* how much we subtract from each p-frame threshold for 2nd, 3rd etc. b-frame in a row */
44    #define P_SENS_BIAS             18
45    
46    /* .. but never below INTER_THRESH_MIN */
47    #define INTER_THRESH_MIN 5
48    
49  static void  static void
50  CheckCandidate32I(const int x, const int y, SearchData * const data, const unsigned int Direction)  CheckCandidate32I(const int x, const int y, SearchData * const data, const unsigned int Direction)
51  {  {
# Line 130  Line 139 
139                  MB->mode = MODE_INTER;                  MB->mode = MODE_INTER;
140                  /* if we skipped some search steps, we have to assume that SAD would be lower with them */                  /* if we skipped some search steps, we have to assume that SAD would be lower with them */
141                  MB->sad16 = Data->iMinSAD[i+1] - (simplicity<<7);                  MB->sad16 = Data->iMinSAD[i+1] - (simplicity<<7);
142                    if (MB->sad16 < 0) MB->sad16 = 0;
143          }          }
144  }  }
145    
# Line 147  Line 157 
157          int sSAD = 0;          int sSAD = 0;
158          MACROBLOCK * const pMBs = Current->mbs;          MACROBLOCK * const pMBs = Current->mbs;
159          const IMAGE * const pCurrent = &Current->image;          const IMAGE * const pCurrent = &Current->image;
160          int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + b_thresh;          int IntraThresh = INTRA_THRESH,
161                    InterThresh = INTER_THRESH + b_thresh,
162                    IntraThresh2 = INTRA_THRESH2;
163    
164          int blocks = 10;          int blocks = 10;
165          int complexity = 0;          int complexity = 0;
166    
# Line 158  Line 171 
171          Data.qpel_precision = 0;          Data.qpel_precision = 0;
172    
173          if (intraCount != 0) {          if (intraCount != 0) {
174                  if (intraCount < 10) /* we're right after an I frame */                  if (intraCount < 30) {
175                          IntraThresh += 15* (intraCount - 10) * (intraCount - 10);                          /* we're right after an I frame
176                  else                             we increase thresholds to prevent consecutive i-frames */
177                          if ( 5*(maxIntra - intraCount) < maxIntra) /* we're close to maximum. 2 sec when max is 10 sec */                          if (intraCount < 10) IntraThresh += 15*(10 - intraCount)*(10 - intraCount);
178                                  IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra;                          IntraThresh2 += 4*(30 - intraCount);
179                    } else if (I_SENS_TH*(maxIntra - intraCount) < maxIntra) {
180                            /* we're close to maximum. we decrease thresholds to catch any good keyframe */
181                            IntraThresh -= IntraThresh*((maxIntra - I_SENS_TH*(maxIntra - intraCount))/maxIntra);
182                            IntraThresh2 -= IntraThresh2*((maxIntra - I_SENS_TH*(maxIntra - intraCount))/maxIntra);
183                    }
184          }          }
185    
186          InterThresh -= 20 * bCount;          InterThresh -= P_SENS_BIAS * bCount;
187          if (InterThresh < 10 + b_thresh) InterThresh = 10 + b_thresh;          if (InterThresh < INTER_THRESH_MIN) InterThresh = INTER_THRESH_MIN;
188    
189          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
190    
# Line 199  Line 217 
217    
218                                  if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0)                                  if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0)
219                                          if (dev > 1000 && pMB->sad16 < 1000)                                          if (dev > 1000 && pMB->sad16 < 1000)
220                                                  sSAD += 1000;                                                  sSAD += 512;
221    
222                                  sSAD += (dev < 4000) ? pMB->sad16 : pMB->sad16/2; /* blocks with big contrast differences usually have large SAD - while they look very good in b-frames */                                  sSAD += (dev < 3000) ? pMB->sad16 : pMB->sad16/2; /* blocks with big contrast differences usually have large SAD - while they look very good in b-frames */
223                          }                          }
224                  }                  }
225          }          }
# Line 209  Line 227 
227    
228          sSAD /= complexity + 4*blocks;          sSAD /= complexity + 4*blocks;
229    
230          if (intraCount > 60 && sSAD > INTRA_THRESH2 ) return I_VOP;          if (sSAD > IntraThresh2) return I_VOP;
231          if (sSAD > InterThresh ) return P_VOP;          if (sSAD > InterThresh ) return P_VOP;
232          emms();          emms();
233          return B_VOP;          return B_VOP;

Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.7

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