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: decoder.c,v 1.51 2004-03-22 22:36:23 edgomez Exp $ |
* $Id: decoder.c,v 1.51.2.7 2004-07-24 11:38:12 edgomez Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
222 |
dec->time = dec->time_base = dec->last_time_base = 0; |
dec->time = dec->time_base = dec->last_time_base = 0; |
223 |
dec->low_delay = 0; |
dec->low_delay = 0; |
224 |
dec->packed_mode = 0; |
dec->packed_mode = 0; |
225 |
|
dec->time_inc_resolution = 1; /* until VOL header says otherwise */ |
226 |
|
|
227 |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
228 |
|
|
339 |
stop_coding_timer(); |
stop_coding_timer(); |
340 |
|
|
341 |
start_timer(); |
start_timer(); |
342 |
add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors); |
add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version); |
343 |
stop_prediction_timer(); |
stop_prediction_timer(); |
344 |
|
|
345 |
start_timer(); |
start_timer(); |
497 |
mv[i] = pMB->mvs[i]; |
mv[i] = pMB->mvs[i]; |
498 |
} |
} |
499 |
|
|
500 |
|
for (i = 0; i < 4; i++) { |
501 |
|
/* clip to valid range */ |
502 |
|
int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel); |
503 |
|
if (mv[i].x > border) { |
504 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
505 |
|
mv[i].x = border; |
506 |
|
} else { |
507 |
|
border = (-(int)x_pos-1) << (5 + dec->quarterpel); |
508 |
|
if (mv[i].x < border) { |
509 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
510 |
|
mv[i].x = border; |
511 |
|
} |
512 |
|
} |
513 |
|
|
514 |
|
border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel); |
515 |
|
if (mv[i].y > border) { |
516 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
517 |
|
mv[i].y = border; |
518 |
|
} else { |
519 |
|
border = (-(int)y_pos-1) << (5 + dec->quarterpel); |
520 |
|
if (mv[i].y < border) { |
521 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
522 |
|
mv[i].y = border; |
523 |
|
} |
524 |
|
} |
525 |
|
} |
526 |
|
|
527 |
start_timer(); |
start_timer(); |
528 |
|
|
529 |
if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */ |
if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */ |
789 |
mv.y -= range; |
mv.y -= range; |
790 |
} |
} |
791 |
|
|
|
/* clip to valid range */ |
|
|
|
|
|
if (mv.x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) ) |
|
|
mv.x = (int)(dec->mb_width - x) << (5 + dec->quarterpel); |
|
|
|
|
|
else if (mv.x < (int)(-x-1) << (5 + dec->quarterpel)) |
|
|
mv.x = (int)(-x-1) << (5 + dec->quarterpel); |
|
|
|
|
|
if (mv.y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) ) |
|
|
mv.y = (int)(dec->mb_height - y) << (5 + dec->quarterpel); |
|
|
|
|
|
else if (mv.y < ((int)(-y-1)) << (5 + dec->quarterpel) ) |
|
|
mv.y = (int)(-y-1) << (5 + dec->quarterpel); |
|
|
|
|
792 |
ret_mv->x = mv.x; |
ret_mv->x = mv.x; |
793 |
ret_mv->y = mv.y; |
ret_mv->y = mv.y; |
794 |
} |
} |
1000 |
else if (mv_y > high) |
else if (mv_y > high) |
1001 |
mv_y -= range; |
mv_y -= range; |
1002 |
|
|
|
|
|
|
/* clip to valid range */ |
|
|
if (mv_x > ((int)(dec->mb_width - x) << (5 + dec->quarterpel)) ) |
|
|
mv_x = (int)(dec->mb_width - x) << (5 + dec->quarterpel); |
|
|
|
|
|
else if (mv_x < (int)(-x-1) << (5 + dec->quarterpel)) |
|
|
mv_x = (int)(-x-1) << (5 + dec->quarterpel); |
|
|
|
|
|
if (mv_y > ((int)(dec->mb_height - y) << (5 + dec->quarterpel)) ) |
|
|
mv_y = (int)(dec->mb_height - y) << (5 + dec->quarterpel); |
|
|
|
|
|
else if (mv_y < ((int)(-y-1)) << (5 + dec->quarterpel) ) |
|
|
mv_y = (int)(-y-1) << (5 + dec->quarterpel); |
|
|
|
|
1003 |
mv->x = mv_x; |
mv->x = mv_x; |
1004 |
mv->y = mv_y; |
mv->y = mv_y; |
1005 |
} |
} |
1140 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1141 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1142 |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos, |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos, |
1143 |
stride, 1, 8); |
stride, 0, 8); |
1144 |
|
|
1145 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1146 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1147 |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1148 |
stride, 1, 8); |
stride, 0, 8); |
1149 |
|
|
1150 |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1151 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1152 |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1153 |
stride, 1, 8); |
stride, 0, 8); |
1154 |
|
|
1155 |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
interpolate8x8_avg2(dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1156 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1157 |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1158 |
stride, 1, 8); |
stride, 0, 8); |
1159 |
|
|
1160 |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1161 |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1162 |
dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos, |
1163 |
stride2, 1, 8); |
stride2, 0, 8); |
1164 |
|
|
1165 |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1166 |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1167 |
dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos, |
1168 |
stride2, 1, 8); |
stride2, 0, 8); |
1169 |
|
|
1170 |
stop_comp_timer(); |
stop_comp_timer(); |
1171 |
|
|
1215 |
uint32_t x, y; |
uint32_t x, y; |
1216 |
VECTOR mv; |
VECTOR mv; |
1217 |
const VECTOR zeromv = {0,0}; |
const VECTOR zeromv = {0,0}; |
|
const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp; |
|
1218 |
int i; |
int i; |
1219 |
|
|
1220 |
start_timer(); |
start_timer(); |
1309 |
|
|
1310 |
case MODE_DIRECT_NONE_MV: |
case MODE_DIRECT_NONE_MV: |
1311 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < 4; i++) { |
1312 |
mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x); |
mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x; |
1313 |
mb->b_mvs[i].x = (int32_t) ((mv.x == 0) |
mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y; |
1314 |
? ((TRB - TRD) * last_mb->mvs[i].x) / TRD |
|
1315 |
: mb->mvs[i].x - last_mb->mvs[i].x); |
mb->b_mvs[i].x = (mv.x) |
1316 |
mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y); |
? mb->mvs[i].x - last_mb->mvs[i].x |
1317 |
mb->b_mvs[i].y = (int32_t) ((mv.y == 0) |
: last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp; |
1318 |
? ((TRB - TRD) * last_mb->mvs[i].y) / TRD |
mb->b_mvs[i].y = (mv.y) |
1319 |
: mb->mvs[i].y - last_mb->mvs[i].y); |
? mb->mvs[i].y - last_mb->mvs[i].y |
1320 |
|
: last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp; |
1321 |
} |
} |
1322 |
|
|
1323 |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1490 |
goto repeat; |
goto repeat; |
1491 |
} |
} |
1492 |
|
|
1493 |
|
if(dec->frames == 0 && coding_type != I_VOP) { |
1494 |
|
/* 1st frame is not an i-vop */ |
1495 |
|
goto repeat; |
1496 |
|
} |
1497 |
|
|
1498 |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; /* init pred vector to 0 */ |
dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; /* init pred vector to 0 */ |
1499 |
|
|
1500 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |
1556 |
|
|
1557 |
if (dec->low_delay) { |
if (dec->low_delay) { |
1558 |
DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n"); |
DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n"); |
1559 |
dec->low_delay = 1; |
dec->low_delay = 0; |
1560 |
} |
} |
1561 |
|
|
1562 |
if (dec->frames < 2) { |
if (dec->frames < 2) { |