4 |
* - Decoder Module - |
* - Decoder Module - |
5 |
* |
* |
6 |
* Copyright(C) 2002 MinChen <chenm001@163.com> |
* Copyright(C) 2002 MinChen <chenm001@163.com> |
7 |
* 2002-2003 Peter Ross <pross@xvid.org> |
* 2002-2004 Peter Ross <pross@xvid.org> |
8 |
* |
* |
9 |
* This program is free software ; you can redistribute it and/or modify |
* This program is free software ; you can redistribute it and/or modify |
10 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
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.55 2004-04-15 12:05:19 suxen_drol Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
496 |
mv[i] = pMB->mvs[i]; |
mv[i] = pMB->mvs[i]; |
497 |
} |
} |
498 |
|
|
499 |
|
for (i = 0; i < 4; i++) { |
500 |
|
/* clip to valid range */ |
501 |
|
int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel); |
502 |
|
if (mv[i].x > border) { |
503 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
504 |
|
mv[i].x = border; |
505 |
|
} else { |
506 |
|
border = (-(int)x_pos-1) << (5 + dec->quarterpel); |
507 |
|
if (mv[i].x < border) { |
508 |
|
DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); |
509 |
|
mv[i].x = border; |
510 |
|
} |
511 |
|
} |
512 |
|
|
513 |
|
border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel); |
514 |
|
if (mv[i].y > border) { |
515 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
516 |
|
mv[i].y = border; |
517 |
|
} else { |
518 |
|
border = (-(int)y_pos-1) << (5 + dec->quarterpel); |
519 |
|
if (mv[i].y < border) { |
520 |
|
DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); |
521 |
|
mv[i].y = border; |
522 |
|
} |
523 |
|
} |
524 |
|
} |
525 |
|
|
526 |
start_timer(); |
start_timer(); |
527 |
|
|
528 |
if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */ |
if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */ |
788 |
mv.y -= range; |
mv.y -= range; |
789 |
} |
} |
790 |
|
|
|
/* 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); |
|
|
|
|
791 |
ret_mv->x = mv.x; |
ret_mv->x = mv.x; |
792 |
ret_mv->y = mv.y; |
ret_mv->y = mv.y; |
793 |
} |
} |
999 |
else if (mv_y > high) |
else if (mv_y > high) |
1000 |
mv_y -= range; |
mv_y -= range; |
1001 |
|
|
|
|
|
|
/* 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); |
|
|
|
|
1002 |
mv->x = mv_x; |
mv->x = mv_x; |
1003 |
mv->y = mv_y; |
mv->y = mv_y; |
1004 |
} |
} |
1360 |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, |
1361 |
int coding_type, int quant) |
int coding_type, int quant) |
1362 |
{ |
{ |
1363 |
|
const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0; |
1364 |
|
|
1365 |
if (dec->cartoon_mode) |
if (dec->cartoon_mode) |
1366 |
frame->general &= ~XVID_FILMEFFECT; |
frame->general &= ~XVID_FILMEFFECT; |
1367 |
|
|
1368 |
if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) && mbs != NULL) /* post process */ |
if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0) |
1369 |
|
&& mbs != NULL) /* post process */ |
1370 |
{ |
{ |
1371 |
/* note: image is stored to tmp */ |
/* note: image is stored to tmp */ |
1372 |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
1373 |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
1374 |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
1375 |
frame->general, dec->frames, (coding_type == B_VOP)); |
frame->general, brightness, dec->frames, (coding_type == B_VOP)); |
1376 |
img = &dec->tmp; |
img = &dec->tmp; |
1377 |
} |
} |
1378 |
|
|