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 |
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 |
|
|
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 |
} |
} |
1361 |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, |
1362 |
int coding_type, int quant) |
int coding_type, int quant) |
1363 |
{ |
{ |
1364 |
|
const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0; |
1365 |
|
|
1366 |
if (dec->cartoon_mode) |
if (dec->cartoon_mode) |
1367 |
frame->general &= ~XVID_FILMEFFECT; |
frame->general &= ~XVID_FILMEFFECT; |
1368 |
|
|
1369 |
if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) && mbs != NULL) /* post process */ |
if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || brightness!=0) |
1370 |
|
&& mbs != NULL) /* post process */ |
1371 |
{ |
{ |
1372 |
/* note: image is stored to tmp */ |
/* note: image is stored to tmp */ |
1373 |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
1374 |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, |
1375 |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
1376 |
frame->general, dec->frames, (coding_type == B_VOP)); |
frame->general, brightness, dec->frames, (coding_type == B_VOP)); |
1377 |
img = &dec->tmp; |
img = &dec->tmp; |
1378 |
} |
} |
1379 |
|
|
1493 |
goto repeat; |
goto repeat; |
1494 |
} |
} |
1495 |
|
|
1496 |
|
if(dec->frames == 0 && coding_type != I_VOP) { |
1497 |
|
/* 1st frame is not an i-vop */ |
1498 |
|
goto repeat; |
1499 |
|
} |
1500 |
|
|
1501 |
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 */ |
1502 |
|
|
1503 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |