572 |
#endif |
#endif |
573 |
} |
} |
574 |
} |
} |
575 |
|
|
576 |
|
bits = BitstreamPos(bs); |
577 |
|
|
578 |
/* code motion vector(s) if motion is local */ |
/* code motion vector(s) if motion is local */ |
579 |
if (!pMB->mcsel) |
if (!pMB->mcsel) |
580 |
for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { |
for (i = 0; i < (pMB->mode == MODE_INTER4V ? 4 : 1); i++) { |
582 |
CodeVector(bs, pMB->pmvs[i].y, frame->fcode); |
CodeVector(bs, pMB->pmvs[i].y, frame->fcode); |
583 |
} |
} |
584 |
|
|
585 |
|
bits = BitstreamPos(bs) - bits; |
586 |
|
pStat->iMVBits += bits; |
587 |
|
|
588 |
bits = BitstreamPos(bs); |
bits = BitstreamPos(bs); |
589 |
|
|
590 |
/* code block coeffs */ |
/* code block coeffs */ |
752 |
} |
} |
753 |
} |
} |
754 |
|
|
755 |
|
bits = BitstreamPos(bs); |
756 |
|
|
757 |
switch (mb->mode) { |
switch (mb->mode) { |
758 |
case MODE_INTERPOLATE: |
case MODE_INTERPOLATE: |
769 |
CodeVector(bs, mb->pmvs[3].y, 1); /* prediction is always (0,0) */ |
CodeVector(bs, mb->pmvs[3].y, 1); /* prediction is always (0,0) */ |
770 |
default: break; |
default: break; |
771 |
} |
} |
772 |
|
pStat->iMVBits += BitstreamPos(bs) - bits; |
773 |
|
|
774 |
bits = BitstreamPos(bs); |
bits = BitstreamPos(bs); |
775 |
for (i = 0; i < 6; i++) { |
for (i = 0; i < 6; i++) { |
1075 |
|
|
1076 |
do { |
do { |
1077 |
level = get_coeff(bs, &run, &last, 1, 0); |
level = get_coeff(bs, &run, &last, 1, 0); |
1078 |
coeff += run; |
if (run == -1) { |
1079 |
if ((run|coeff)&~63) { |
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
|
1080 |
break; |
break; |
1081 |
} |
} |
1082 |
|
coeff += run; |
1083 |
|
|
1084 |
|
#ifdef _DEBUG |
1085 |
|
if(coeff>=64) { |
1086 |
|
DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); |
1087 |
|
return; |
1088 |
|
} |
1089 |
|
#endif |
1090 |
|
|
1091 |
block[scan[coeff]] = level; |
block[scan[coeff]] = level; |
1092 |
|
|
1123 |
p = 0; |
p = 0; |
1124 |
do { |
do { |
1125 |
level = get_coeff(bs, &run, &last, 0, 0); |
level = get_coeff(bs, &run, &last, 0, 0); |
1126 |
p += run; |
if (run == -1) { |
1127 |
if ((run|p)&~63) { |
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
|
1128 |
break; |
break; |
1129 |
} |
} |
1130 |
|
p += run; |
1131 |
|
|
1132 |
|
#ifdef _DEBUG |
1133 |
|
if(p>=64) { |
1134 |
|
DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); |
1135 |
|
return; |
1136 |
|
} |
1137 |
|
#endif |
1138 |
|
|
1139 |
if (level < 0) { |
if (level < 0) { |
1140 |
level = level*quant_m_2 - quant_add; |
level = level*quant_m_2 - quant_add; |
1165 |
p = 0; |
p = 0; |
1166 |
do { |
do { |
1167 |
level = get_coeff(bs, &run, &last, 0, 0); |
level = get_coeff(bs, &run, &last, 0, 0); |
1168 |
p += run; |
if (run == -1) { |
1169 |
if ((run|p)&~63) { |
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run"); |
|
DPRINTF(XVID_DEBUG_ERROR,"fatal: invalid run or index"); |
|
1170 |
break; |
break; |
1171 |
} |
} |
1172 |
|
p += run; |
1173 |
|
|
1174 |
|
#ifdef _DEBUG |
1175 |
|
if(p>=64) { |
1176 |
|
DPRINTF(XVID_DEBUG_ERROR,"error: overflow in coefficient index\n"); |
1177 |
|
return; |
1178 |
|
} |
1179 |
|
#endif |
1180 |
|
|
1181 |
if (level < 0) { |
if (level < 0) { |
1182 |
level = ((2 * -level + 1) * matrix[scan[p]] * quant) >> 4; |
level = ((2 * -level + 1) * matrix[scan[p]] * quant) >> 4; |