--- mbcoding.c 2007/04/28 16:30:20 1.54 +++ mbcoding.c 2008/11/26 01:04:34 1.57 @@ -19,7 +19,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: mbcoding.c,v 1.54 2007/04/28 16:30:20 syskin Exp $ + * $Id: mbcoding.c,v 1.57 2008/11/26 01:04:34 Isibaar Exp $ * ****************************************************************************/ @@ -1075,7 +1075,7 @@ return (level << 20) >> 20; error: - *run = VLC_ERROR; + *run = 64; return 0; } @@ -1087,22 +1087,15 @@ { const uint16_t *scan = scan_tables[direction]; - int level, run, last; + int level, run, last = 0; do { level = get_coeff(bs, &run, &last, 1, 0); - if (run == -1) { - DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); - break; - } coeff += run; - -#ifdef _DEBUG - if(coeff>=64) { - DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); - return; + if (coeff & ~63) { + DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); + break; } -#endif block[scan[coeff]] = level; @@ -1134,23 +1127,16 @@ int p; int level; int run; - int last; + int last = 0; p = 0; do { level = get_coeff(bs, &run, &last, 0, 0); - if (run == -1) { - DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); - break; - } p += run; - -#ifdef _DEBUG - if(p>=64) { - DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); - return; + if (p & ~63) { + DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); + break; } -#endif if (level < 0) { level = level*quant_m_2 - quant_add; @@ -1176,23 +1162,16 @@ int p; int level; int run; - int last; + int last = 0; p = 0; do { level = get_coeff(bs, &run, &last, 0, 0); - if (run == -1) { - DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); - break; - } p += run; - -#ifdef _DEBUG - if(p>=64) { - DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); - return; + if (p & ~63) { + DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); + break; } -#endif if (level < 0) { level = ((2 * -level + 1) * matrix[scan[p]] * quant) >> 4;