[svn] / trunk / xvidcore / src / prediction / mbprediction.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/prediction/mbprediction.c

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

revision 1471, Fri Jun 11 08:44:30 2004 UTC revision 1472, Sat Jun 12 13:02:12 2004 UTC
# Line 20  Line 20 
20   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
21   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22   *   *
23   * $Id: mbprediction.c,v 1.15 2004-05-21 14:40:15 edgomez Exp $   * $Id: mbprediction.c,v 1.16 2004-06-12 13:02:12 edgomez Exp $
24   *   *
25   ****************************************************************************/   ****************************************************************************/
26    
# Line 67  Line 67 
67                           uint32_t current_quant,                           uint32_t current_quant,
68                           int32_t iDcScaler,                           int32_t iDcScaler,
69                           int16_t predictors[8],                           int16_t predictors[8],
70                           const int bound,                           const int bound)
                          const int bsversion)  
71    
72  {  {
73          const int mbpos = (y * mb_width) + x;          const int mbpos = (y * mb_width) + x;
# Line 187  Line 186 
186    
187          /* determine ac prediction direction & ac/dc predictor place rescaled ac/dc          /* determine ac prediction direction & ac/dc predictor place rescaled ac/dc
188           * predictions into predictors[] for later use */           * predictions into predictors[] for later use */
   
         /* Workaround: Bitstream versions <= 32 used to have a wrong predictor  
          * stored as it wasn't clipped to the [-2048, 2047] range. We only  
          * use the right predictors for bs versions > 32 */  
 #define BUGGY_CLIPPING_BS_VERSION 32  
189          if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) {          if (abs(pLeft[0] - pDiag[0]) < abs(pDiag[0] - pTop[0])) {
190                  *acpred_direction = 1;  /* vertical */                  *acpred_direction = 1;  /* vertical */
191                  predictors[0] = DIV_DIV(pTop[0], iDcScaler);                  predictors[0] = DIV_DIV(pTop[0], iDcScaler);
                 if (bsversion == 0 || bsversion > BUGGY_CLIPPING_BS_VERSION)  
                         predictors[0] = CLIP(predictors[0], -2048, 2047);  
192                  for (i = 1; i < 8; i++) {                  for (i = 1; i < 8; i++) {
193                          predictors[i] = rescale(top_quant, current_quant, pTop[i]);                          predictors[i] = rescale(top_quant, current_quant, pTop[i]);
194                  }                  }
195          } else {          } else {
196                  *acpred_direction = 2;  /* horizontal */                  *acpred_direction = 2;  /* horizontal */
197                  predictors[0] = DIV_DIV(pLeft[0], iDcScaler);                  predictors[0] = DIV_DIV(pLeft[0], iDcScaler);
                 if (bsversion == 0 || bsversion > BUGGY_CLIPPING_BS_VERSION)  
                         predictors[0] = CLIP(predictors[0], -2048, 2047);  
198                  for (i = 1; i < 8; i++) {                  for (i = 1; i < 8; i++) {
199                          predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]);                          predictors[i] = rescale(left_quant, current_quant, pLeft[i + 7]);
200                  }                  }
# Line 216  Line 206 
206     store current coeffs to pred_values[] for future prediction     store current coeffs to pred_values[] for future prediction
207  */  */
208    
209    /* Up to this version, no DC clipping was performed, so we try to be backward
210     * compatible to avoid artifacts */
211    #define BS_VERSION_BUGGY_DC_CLIPPING 34
212    
213  void  void
214  add_acdc(MACROBLOCK * pMB,  add_acdc(MACROBLOCK * pMB,
215                   uint32_t block,                   uint32_t block,
216                   int16_t dct_codes[64],                   int16_t dct_codes[64],
217                   uint32_t iDcScaler,                   uint32_t iDcScaler,
218                   int16_t predictors[8])                   int16_t predictors[8],
219                     const int bsversion)
220  {  {
221          uint8_t acpred_direction = pMB->acpred_directions[block];          uint8_t acpred_direction = pMB->acpred_directions[block];
222          int16_t *pCurrent = pMB->pred_values[block];          int16_t *pCurrent = pMB->pred_values[block];
# Line 232  Line 226 
226    
227          dct_codes[0] += predictors[0];  /* dc prediction */          dct_codes[0] += predictors[0];  /* dc prediction */
228          pCurrent[0] = dct_codes[0] * iDcScaler;          pCurrent[0] = dct_codes[0] * iDcScaler;
229            if (!bsversion || bsversion > BS_VERSION_BUGGY_DC_CLIPPING) {
230                    pCurrent[0] = CLIP(pCurrent[0], -2048, 2047);
231            }
232    
233          if (acpred_direction == 1) {          if (acpred_direction == 1) {
234                  for (i = 1; i < 8; i++) {                  for (i = 1; i < 8; i++) {
# Line 288  Line 285 
285          /* store current coeffs to pred_values[] for future prediction */          /* store current coeffs to pred_values[] for future prediction */
286    
287          pCurrent[0] = qcoeff[0] * iDcScaler;          pCurrent[0] = qcoeff[0] * iDcScaler;
288            pCurrent[0] = CLIP(pCurrent[0], -2048, 2047);
289          for (i = 1; i < 8; i++) {          for (i = 1; i < 8; i++) {
290                  pCurrent[i] = qcoeff[i];                  pCurrent[i] = qcoeff[i];
291                  pCurrent[i + 7] = qcoeff[i * 8];                  pCurrent[i + 7] = qcoeff[i * 8];
# Line 344  Line 342 
342    
343          /* store current coeffs to pred_values[] for future prediction */          /* store current coeffs to pred_values[] for future prediction */
344          pCurrent[0] = qcoeff[0] * iDcScaler;          pCurrent[0] = qcoeff[0] * iDcScaler;
345            pCurrent[0] = CLIP(pCurrent[0], -2048, 2047);
346          for (i = 1; i < 8; i++) {          for (i = 1; i < 8; i++) {
347                  pCurrent[i] = qcoeff[i];                  pCurrent[i] = qcoeff[i];
348                  pCurrent[i + 7] = qcoeff[i * 8];                  pCurrent[i + 7] = qcoeff[i * 8];
# Line 427  Line 426 
426                          iDcScaler = get_dc_scaler(iQuant, j<4);                          iDcScaler = get_dc_scaler(iQuant, j<4);
427    
428                          predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],                          predict_acdc(frame->mbs, x, y, mb_width, j, &qcoeff[j * 64],
429                                                   iQuant, iDcScaler, predictors[j], 0, 0);                                                   iQuant, iDcScaler, predictors[j], 0);
430    
431                          if ((frame->vop_flags & XVID_VOP_HQACPRED))                          if ((frame->vop_flags & XVID_VOP_HQACPRED))
432                                  S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);                                  S += calc_acdc_bits(pMB, j, &qcoeff[j * 64], iDcScaler, predictors[j]);

Legend:
Removed from v.1471  
changed lines
  Added in v.1472

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