[svn] / branches / dev-api-4 / xvidcore / src / motion / vop_type_decision.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/motion/vop_type_decision.c

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

revision 1215, Wed Nov 19 12:24:25 2003 UTC revision 1239, Thu Dec 4 12:08:03 2003 UTC
# Line 19  Line 19 
19   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
20   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   *   *
22   * $Id: vop_type_decision.c,v 1.1.2.5 2003-11-19 12:24:25 syskin Exp $   * $Id: vop_type_decision.c,v 1.1.2.6 2003-12-04 12:08:03 syskin Exp $
23   *   *
24   ****************************************************************************/   ****************************************************************************/
25    
# 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 147  Line 156 
156          int sSAD = 0;          int sSAD = 0;
157          MACROBLOCK * const pMBs = Current->mbs;          MACROBLOCK * const pMBs = Current->mbs;
158          const IMAGE * const pCurrent = &Current->image;          const IMAGE * const pCurrent = &Current->image;
159          int IntraThresh = INTRA_THRESH, InterThresh = INTER_THRESH + b_thresh;          int IntraThresh = INTRA_THRESH,
160                    InterThresh = INTER_THRESH + b_thresh,
161                    IntraThresh2 = INTRA_THRESH2;
162    
163          int blocks = 10;          int blocks = 10;
164          int complexity = 0;          int complexity = 0;
165    
# Line 158  Line 170 
170          Data.qpel_precision = 0;          Data.qpel_precision = 0;
171    
172          if (intraCount != 0) {          if (intraCount != 0) {
173                  if (intraCount < 10) /* we're right after an I frame */                  if (intraCount < 30) {
174                          IntraThresh += 15* (intraCount - 10) * (intraCount - 10);                          /* we're right after an I frame
175                  else                             we increase thresholds to prevent consecutive i-frames */
176                          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);
177                                  IntraThresh -= (IntraThresh * (maxIntra - 8*(maxIntra - intraCount)))/maxIntra;                          IntraThresh2 += 4*(30 - intraCount);
178                    } else if (I_SENS_TH*(maxIntra - intraCount) < maxIntra) {
179                            /* we're close to maximum. we decrease thresholds to catch any good keyframe */
180                            IntraThresh -= IntraThresh*((maxIntra - I_SENS_TH*(maxIntra - intraCount))/maxIntra);
181                            IntraThresh2 -= IntraThresh2*((maxIntra - I_SENS_TH*(maxIntra - intraCount))/maxIntra);
182                    }
183          }          }
184    
185          InterThresh -= 20 * bCount;          InterThresh -= P_SENS_BIAS * bCount;
186          if (InterThresh < 10 + b_thresh) InterThresh = 10 + b_thresh;          if (InterThresh < INTER_THRESH_MIN) InterThresh = INTER_THRESH_MIN;
187    
188          if (sadInit) (*sadInit) ();          if (sadInit) (*sadInit) ();
189    
# Line 199  Line 216 
216    
217                                  if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0)                                  if (pMB->mvs[0].x == 0 && pMB->mvs[0].y == 0)
218                                          if (dev > 1000 && pMB->sad16 < 1000)                                          if (dev > 1000 && pMB->sad16 < 1000)
219                                                  sSAD += 1000;                                                  sSAD += 512;
220    
221                                  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 */
222                          }                          }
223                  }                  }
224          }          }
# Line 209  Line 226 
226    
227          sSAD /= complexity + 4*blocks;          sSAD /= complexity + 4*blocks;
228    
229          if (intraCount > 60 && sSAD > INTRA_THRESH2 ) return I_VOP;          if (sSAD > IntraThresh2) return I_VOP;
230          if (sSAD > InterThresh ) return P_VOP;          if (sSAD > InterThresh ) return P_VOP;
231          emms();          emms();
232          return B_VOP;          return B_VOP;

Legend:
Removed from v.1215  
changed lines
  Added in v.1239

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