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

Diff of /xvidcore/src/decoder.c

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

revision 1.65, Tue Aug 10 21:58:55 2004 UTC revision 1.66, Sun Aug 15 11:28:38 2004 UTC
# Line 465  Line 465 
465          }          }
466  }  }
467    
468    static void
469    validate_vector(VECTOR * mv, unsigned int x_pos, unsigned int y_pos, const DECODER * dec)
470    {
471            /* clip a vector to valid range
472               prevents crashes if bitstream is broken
473            */
474            int i;
475    
476            for (i = 0; i < 4; i++) {
477    
478                    int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);
479                    if (mv[i].x > border) {
480                            DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
481                            mv[i].x = border;
482                    } else {
483                            border = (-(int)x_pos-1) << (5 + dec->quarterpel);
484                            if (mv[i].x < border) {
485                                    DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);
486                                    mv[i].x = border;
487                            }
488                    }
489    
490                    border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);
491                    if (mv[i].y >  border) {
492                            DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
493                            mv[i].y = border;
494                    } else {
495                            border = (-(int)y_pos-1) << (5 + dec->quarterpel);
496                            if (mv[i].y < border) {
497                                    DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);
498                                    mv[i].y = border;
499                            }
500                    }
501            }
502    }
503    
504  /* decode an inter macroblock */  /* decode an inter macroblock */
505  static void  static void
506  decoder_mbinter(DECODER * dec,  decoder_mbinter(DECODER * dec,
# Line 502  Line 538 
538                          mv[i] = pMB->mvs[i];                          mv[i] = pMB->mvs[i];
539          }          }
540    
541          for (i = 0; i < 4; i++) {          validate_vector(mv, x_pos, y_pos, dec);
                 /* clip to valid range */  
                 int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel);  
                 if (mv[i].x > border) {  
                         DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);  
                         mv[i].x = border;  
                 } else {  
                         border = (-(int)x_pos-1) << (5 + dec->quarterpel);  
                         if (mv[i].x < border) {  
                                 DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos);  
                                 mv[i].x = border;  
                         }  
                 }  
   
                 border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel);  
                 if (mv[i].y >  border) {  
                         DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);  
                         mv[i].y = border;  
                 } else {  
                         border = (-(int)y_pos-1) << (5 + dec->quarterpel);  
                         if (mv[i].y < border) {  
                                 DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos);  
                                 mv[i].y = border;  
                         }  
                 }  
         }  
542    
543          start_timer();          start_timer();
544    
# Line 1017  Line 1028 
1028  decoder_bf_interpolate_mbinter(DECODER * dec,  decoder_bf_interpolate_mbinter(DECODER * dec,
1029                                                                  IMAGE forward,                                                                  IMAGE forward,
1030                                                                  IMAGE backward,                                                                  IMAGE backward,
1031                                                                  const MACROBLOCK * pMB,                                                                  MACROBLOCK * pMB,
1032                                                                  const uint32_t x_pos,                                                                  const uint32_t x_pos,
1033                                                                  const uint32_t y_pos,                                                                  const uint32_t y_pos,
1034                                                                  Bitstream * bs,                                                                  Bitstream * bs,
# Line 1034  Line 1045 
1045          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);          pU_Cur = dec->cur.u + (y_pos << 3) * stride2 + (x_pos << 3);
1046          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);          pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3);
1047    
1048            validate_vector(pMB->mvs, x_pos, y_pos, dec);
1049            validate_vector(pMB->b_mvs, x_pos, y_pos, dec);
1050    
1051          if (!direct) {          if (!direct) {
1052                  uv_dx = pMB->mvs[0].x;                  uv_dx = pMB->mvs[0].x;
1053                  uv_dy = pMB->mvs[0].y;                  uv_dy = pMB->mvs[0].y;
# Line 1381  Line 1395 
1395          }          }
1396  }  }
1397    
   
1398  int  int
1399  decoder_decode(DECODER * dec,  decoder_decode(DECODER * dec,
1400                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)                                  xvid_dec_frame_t * frame, xvid_dec_stats_t * stats)

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66

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