--- decoder.c 2004/04/19 12:33:34 1.51.2.2 +++ decoder.c 2004/04/10 04:30:07 1.53 @@ -4,7 +4,7 @@ * - Decoder Module - * * Copyright(C) 2002 MinChen - * 2002-2003 Peter Ross + * 2002-2004 Peter Ross * * This program is free software ; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: decoder.c,v 1.51.2.2 2004/04/19 12:33:34 syskin Exp $ + * $Id: decoder.c,v 1.53 2004/04/10 04:30:07 suxen_drol Exp $ * ****************************************************************************/ @@ -222,7 +222,6 @@ dec->time = dec->time_base = dec->last_time_base = 0; dec->low_delay = 0; dec->packed_mode = 0; - dec->time_inc_resolution = 1; /* until VOL header says otherwise */ dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); @@ -497,33 +496,6 @@ mv[i] = pMB->mvs[i]; } - for (i = 0; i < 4; i++) { - /* clip to valid range */ - int border = (int)(dec->mb_width - x_pos) << (5 + dec->quarterpel); - if (mv[i].x > border) { - DPRINTF(XVID_DEBUG_MV, "mv.x > max -- %d > %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); - mv[i].x = border; - } else { - border = (-(int)x_pos-1) << (5 + dec->quarterpel); - if (mv[i].x < border) { - DPRINTF(XVID_DEBUG_MV, "mv.x < min -- %d < %d, MB %d, %d", mv[i].x, border, x_pos, y_pos); - mv[i].x = border; - } - } - - border = (int)(dec->mb_height - y_pos) << (5 + dec->quarterpel); - if (mv[i].y > border) { - DPRINTF(XVID_DEBUG_MV, "mv.y > max -- %d > %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); - mv[i].y = border; - } else { - border = (-(int)y_pos-1) << (5 + dec->quarterpel); - if (mv[i].y < border) { - DPRINTF(XVID_DEBUG_MV, "mv.y < min -- %d < %d, MB %d, %d", mv[i].y, border, x_pos, y_pos); - mv[i].y = border; - } - } - } - start_timer(); if (pMB->mode != MODE_INTER4V) { /* INTER, INTER_Q, NOT_CODED, FORWARD, BACKWARD */ @@ -789,6 +761,20 @@ mv.y -= range; } + /* 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); + ret_mv->x = mv.x; ret_mv->y = mv.y; } @@ -1000,6 +986,20 @@ else if (mv_y > high) mv_y -= range; + + /* 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); + mv->x = mv_x; mv->y = mv_y; } @@ -1364,13 +1364,14 @@ if (dec->cartoon_mode) frame->general &= ~XVID_FILMEFFECT; - if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) && mbs != NULL) /* post process */ + if ((frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV|XVID_FILMEFFECT) || frame->brightness!=0) + && mbs != NULL) /* post process */ { /* note: image is stored to tmp */ image_copy(&dec->tmp, img, dec->edged_width, dec->height); image_postproc(&dec->postproc, &dec->tmp, dec->edged_width, mbs, dec->mb_width, dec->mb_height, dec->mb_width, - frame->general, dec->frames, (coding_type == B_VOP)); + frame->general, frame->brightness, dec->frames, (coding_type == B_VOP)); img = &dec->tmp; } @@ -1452,6 +1453,7 @@ success = 0; output = 0; + if (stats) stats->type = XVID_TYPE_NOTHING; seen_something = 0; repeat: @@ -1490,11 +1492,6 @@ goto repeat; } - if(dec->frames == 0 && coding_type != I_VOP) { - /* 1st frame is not an i-vop */ - goto repeat; - } - dec->p_bmv.x = dec->p_bmv.y = dec->p_fmv.y = dec->p_fmv.y = 0; /* init pred vector to 0 */ /* packed_mode: special-N_VOP treament */