1138 |
|
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
1139 |
|
|
1140 |
|
|
1141 |
< |
if (!(pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) { |
1142 |
< |
uv_dx = pMB->mvs[0].x; |
1143 |
< |
uv_dy = pMB->mvs[0].y; |
1141 |
> |
uv_dx = pMB->mvs[0].x; |
1142 |
> |
uv_dy = pMB->mvs[0].y; |
1143 |
|
|
1144 |
< |
if (dec->quarterpel) |
1146 |
< |
{ |
1144 |
> |
if (dec->quarterpel) { |
1145 |
|
uv_dx /= 2; |
1146 |
|
uv_dy /= 2; |
1149 |
– |
} |
1150 |
– |
|
1151 |
– |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
1152 |
– |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
1153 |
– |
} else { |
1154 |
– |
int sum; |
1155 |
– |
|
1156 |
– |
if(dec->quarterpel) |
1157 |
– |
sum = (pMB->mvs[0].x / 2) + (pMB->mvs[1].x / 2) + (pMB->mvs[2].x / 2) + (pMB->mvs[3].x / 2); |
1158 |
– |
else |
1159 |
– |
sum = pMB->mvs[0].x + pMB->mvs[1].x + pMB->mvs[2].x + pMB->mvs[3].x; |
1160 |
– |
|
1161 |
– |
uv_dx = (sum >> 3) + roundtab_76[sum & 0xf]; |
1162 |
– |
|
1163 |
– |
if(dec->quarterpel) |
1164 |
– |
sum = (pMB->mvs[0].y / 2) + (pMB->mvs[1].y / 2) + (pMB->mvs[2].y / 2) + (pMB->mvs[3].y / 2); |
1165 |
– |
else |
1166 |
– |
sum = pMB->mvs[0].y + pMB->mvs[1].y + pMB->mvs[2].y + pMB->mvs[3].y; |
1167 |
– |
|
1168 |
– |
uv_dy = (sum >> 3) + roundtab_76[sum & 0xf]; |
1147 |
|
} |
1148 |
|
|
1149 |
+ |
uv_dx = (uv_dx >> 1) + roundtab_79[uv_dx & 0x3]; |
1150 |
+ |
uv_dy = (uv_dy >> 1) + roundtab_79[uv_dy & 0x3]; |
1151 |
+ |
|
1152 |
|
start_timer(); |
1153 |
|
if(dec->quarterpel) { |
1154 |
|
interpolate16x16_quarterpel(dec->cur.y, dec->refn[ref].y, dec->qtmp.y, dec->qtmp.y + 64, |
1155 |
|
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
1156 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1157 |
< |
} |
1177 |
< |
else { |
1157 |
> |
} else { |
1158 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos, 16*y_pos, |
1159 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1160 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos + 8, 16*y_pos, |
1161 |
< |
pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
1161 |
> |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1162 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos, 16*y_pos + 8, |
1163 |
< |
pMB->mvs[2].x, pMB->mvs[2].y, stride, 0); |
1163 |
> |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1164 |
|
interpolate8x8_switch(dec->cur.y, dec->refn[ref].y, 16*x_pos + 8, 16*y_pos + 8, |
1165 |
< |
pMB->mvs[3].x, pMB->mvs[3].y, stride, 0); |
1165 |
> |
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1166 |
|
} |
1167 |
|
|
1168 |
|
interpolate8x8_switch(dec->cur.u, dec->refn[ref].u, 8 * x_pos, 8 * y_pos, |
1174 |
|
for (i = 0; i < 6; i++) { |
1175 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1176 |
|
|
1177 |
< |
if (cbp & (1 << (5 - i))) /* coded */ |
1178 |
< |
{ |
1177 |
> |
if (cbp & (1 << (5 - i))) { /* coded */ |
1178 |
> |
|
1179 |
|
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
1180 |
|
|
1181 |
|
start_timer(); |
1183 |
|
stop_coding_timer(); |
1184 |
|
|
1185 |
|
start_timer(); |
1186 |
< |
if (dec->quant_type == 0) { |
1186 |
> |
if (dec->quant_type == 0) |
1187 |
|
dequant_h263_inter(&data[i * 64], &block[i * 64], iQuant); |
1188 |
< |
} else { |
1188 |
> |
else |
1189 |
|
dequant_mpeg_inter(&data[i * 64], &block[i * 64], iQuant); |
1190 |
< |
} |
1190 |
> |
|
1191 |
|
stop_iquant_timer(); |
1192 |
|
|
1193 |
|
start_timer(); |
1217 |
|
stop_transfer_timer(); |
1218 |
|
} |
1219 |
|
|
1220 |
< |
/* decode an B-frame direct & inter macroblock */ |
1220 |
> |
/* decode an B-frame direct & interpolate macroblock */ |
1221 |
|
void |
1222 |
|
decoder_bf_interpolate_mbinter(DECODER * dec, |
1223 |
|
IMAGE forward, |
1225 |
|
const MACROBLOCK * pMB, |
1226 |
|
const uint32_t x_pos, |
1227 |
|
const uint32_t y_pos, |
1228 |
< |
Bitstream * bs) |
1228 |
> |
Bitstream * bs, |
1229 |
> |
const int direct) |
1230 |
|
{ |
1231 |
|
|
1232 |
|
DECLARE_ALIGNED_MATRIX(block, 6, 64, int16_t, CACHE_LINE); |
1247 |
|
pV_Cur = dec->cur.v + (y_pos << 3) * stride2 + (x_pos << 3); |
1248 |
|
|
1249 |
|
|
1250 |
< |
if ((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) { |
1250 |
> |
if (!direct) { |
1251 |
|
uv_dx = pMB->mvs[0].x; |
1252 |
|
uv_dy = pMB->mvs[0].y; |
1253 |
|
|
1304 |
|
|
1305 |
|
start_timer(); |
1306 |
|
if(dec->quarterpel) { |
1307 |
< |
if((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) |
1307 |
> |
if(!direct) |
1308 |
|
interpolate16x16_quarterpel(dec->cur.y, forward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1309 |
|
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
1310 |
|
pMB->mvs[0].x, pMB->mvs[0].y, stride, 0); |
1342 |
|
|
1343 |
|
|
1344 |
|
if(dec->quarterpel) { |
1345 |
< |
if((pMB->mode == MODE_INTER || pMB->mode == MODE_INTER_Q)) |
1345 |
> |
if(!direct) |
1346 |
|
interpolate16x16_quarterpel(dec->tmp.y, backward.y, dec->qtmp.y, dec->qtmp.y + 64, |
1347 |
|
dec->qtmp.y + 128, 16*x_pos, 16*y_pos, |
1348 |
|
pMB->b_mvs[0].x, pMB->b_mvs[0].y, stride, 0); |
1415 |
|
for (i = 0; i < 6; i++) { |
1416 |
|
int direction = dec->alternate_vertical_scan ? 2 : 0; |
1417 |
|
|
1418 |
< |
if (cbp & (1 << (5 - i))) /* coded */ |
1438 |
< |
{ |
1418 |
> |
if (cbp & (1 << (5 - i))) { /* coded */ |
1419 |
|
memset(&block[i * 64], 0, 64 * sizeof(int16_t)); /* clear */ |
1420 |
|
|
1421 |
|
start_timer(); |
1508 |
|
FILE *fp; |
1509 |
|
static char first=0; |
1510 |
|
#define BFRAME_DEBUG if (!first && fp){ \ |
1511 |
< |
fprintf(fp,"Y=%3d X=%3d MB=%2d CBP=%02X\n",y,x,mb->mb_type,mb->cbp); \ |
1511 |
> |
fprintf(fp,"Y=%3d X=%3d MB=%2d CBP=%02X\n",y,x,mb->mode,mb->cbp); \ |
1512 |
|
} |
1513 |
|
#endif |
1514 |
|
|
1545 |
|
if (last_mb->mode == MODE_NOT_CODED) { |
1546 |
|
/* DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); */ |
1547 |
|
mb->cbp = 0; |
1548 |
< |
#ifdef BFRAMES_DEC_DEBUG |
1569 |
< |
mb->mb_type = MODE_NOT_CODED; |
1570 |
< |
BFRAME_DEBUG |
1571 |
< |
#endif |
1572 |
< |
mb->mb_type = MODE_FORWARD; |
1548 |
> |
mb->mode = MODE_FORWARD; |
1549 |
|
mb->quant = last_mb->quant; |
1550 |
|
/* |
1551 |
|
mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = mb->mvs[0].x; |
1559 |
|
if (!BitstreamGetBit(bs)) { /* modb=='0' */ |
1560 |
|
const uint8_t modb2 = BitstreamGetBit(bs); |
1561 |
|
|
1562 |
< |
mb->mb_type = get_mbtype(bs); |
1562 |
> |
mb->mode = get_mbtype(bs); |
1563 |
|
|
1564 |
|
if (!modb2) { /* modb=='00' */ |
1565 |
|
mb->cbp = BitstreamGetBits(bs, 6); |
1566 |
|
} else { |
1567 |
|
mb->cbp = 0; |
1568 |
|
} |
1569 |
< |
if (mb->mb_type && mb->cbp) { |
1569 |
> |
if (mb->mode && mb->cbp) { |
1570 |
|
quant += get_dbquant(bs); |
1571 |
|
|
1572 |
|
if (quant > 31) { |
1582 |
|
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
1583 |
|
} |
1584 |
|
|
1585 |
< |
if (mb->mb_type) { |
1585 |
> |
if (mb->mode) { |
1586 |
|
mb->field_pred = BitstreamGetBit(bs); |
1587 |
|
DPRINTF(XVID_DEBUG_MB, "decp: field_pred: %i\n", mb->field_pred); |
1588 |
|
|
1596 |
|
} |
1597 |
|
|
1598 |
|
} else { |
1599 |
< |
mb->mb_type = MODE_DIRECT_NONE_MV; |
1599 |
> |
mb->mode = MODE_DIRECT_NONE_MV; |
1600 |
|
mb->cbp = 0; |
1601 |
|
} |
1602 |
|
|
1603 |
|
mb->quant = quant; |
1604 |
< |
mb->mode = MODE_INTER4V; |
1629 |
< |
/* DEBUG1("Switch bm_type=",mb->mb_type); */ |
1604 |
> |
/* DEBUG1("Switch bm_type=",mb->mode); */ |
1605 |
|
|
1606 |
|
#ifdef BFRAMES_DEC_DEBUG |
1607 |
|
BFRAME_DEBUG |
1608 |
|
#endif |
1609 |
|
|
1610 |
< |
switch (mb->mb_type) { |
1610 |
> |
switch (mb->mode) { |
1611 |
|
case MODE_DIRECT: |
1612 |
|
get_b_motion_vector(dec, bs, x, y, &mv, 1, zeromv); |
1613 |
|
|
1633 |
|
/* DEBUG("B-frame Direct!\n"); */ |
1634 |
|
} |
1635 |
|
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1636 |
< |
mb, x, y, bs); |
1636 |
> |
mb, x, y, bs, 1); |
1637 |
|
break; |
1638 |
|
|
1639 |
|
case MODE_INTERPOLATE: |
1647 |
|
mb->b_mvs[3] = mb->b_mvs[0]; |
1648 |
|
|
1649 |
|
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1650 |
< |
mb, x, y, bs); |
1650 |
> |
mb, x, y, bs, 0); |
1651 |
|
/* DEBUG("B-frame Bidir!\n"); */ |
1652 |
|
break; |
1653 |
|
|
1656 |
|
dec->p_bmv); |
1657 |
|
dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1658 |
|
|
1684 |
– |
mb->mode = MODE_INTER; |
1659 |
|
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 0); |
1660 |
|
/* DEBUG("B-frame Backward!\n"); */ |
1661 |
|
break; |
1665 |
|
dec->p_fmv); |
1666 |
|
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1667 |
|
|
1694 |
– |
mb->mode = MODE_INTER; |
1668 |
|
decoder_bf_mbinter(dec, mb, x, y, mb->cbp, bs, quant, 1); |
1669 |
|
/* DEBUG("B-frame Forward!\n"); */ |
1670 |
|
break; |
1671 |
|
|
1672 |
|
default: |
1673 |
< |
DPRINTF(XVID_DEBUG_ERROR,"Not support B-frame mb_type = %i\n", mb->mb_type); |
1673 |
> |
DPRINTF(XVID_DEBUG_ERROR,"Not supported B-frame mb_type = %i\n", mb->mode); |
1674 |
|
} |
1675 |
|
} /* End of for */ |
1676 |
|
} |