--- decoder.c 2004/04/19 12:33:34 1.51.2.2 +++ decoder.c 2004/06/12 13:02:12 1.59 @@ -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.59 2004/06/12 13:02:12 edgomez Exp $ * ****************************************************************************/ @@ -339,7 +339,7 @@ stop_coding_timer(); start_timer(); - add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors); + add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version); stop_prediction_timer(); start_timer(); @@ -815,10 +815,13 @@ mb_height = (dec->height + 31) / 32; } - start_timer(); - image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->bs_version); - stop_edges_timer(); + if (!dec->is_edged[0]) { + start_timer(); + image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, + dec->width, dec->height, dec->bs_version); + dec->is_edged[0] = 1; + stop_edges_timer(); + } if (gmc_warp) { /* accuracy: 0==1/2, 1=1/4, 2=1/8, 3=1/16 */ @@ -1215,15 +1218,23 @@ uint32_t x, y; VECTOR mv; const VECTOR zeromv = {0,0}; - const int64_t TRB = dec->time_pp - dec->time_bp, TRD = dec->time_pp; int i; - start_timer(); - image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->bs_version); - image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, - dec->width, dec->height, dec->bs_version); - stop_edges_timer(); + if (!dec->is_edged[0]) { + start_timer(); + image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, + dec->width, dec->height, dec->bs_version); + dec->is_edged[0] = 1; + stop_edges_timer(); + } + + if (!dec->is_edged[1]) { + start_timer(); + image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, + dec->width, dec->height, dec->bs_version); + dec->is_edged[1] = 1; + stop_edges_timer(); + } for (y = 0; y < dec->mb_height; y++) { /* Initialize Pred Motion Vector */ @@ -1310,14 +1321,15 @@ case MODE_DIRECT_NONE_MV: for (i = 0; i < 4; i++) { - mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x); - mb->b_mvs[i].x = (int32_t) ((mv.x == 0) - ? ((TRB - TRD) * last_mb->mvs[i].x) / TRD - : mb->mvs[i].x - last_mb->mvs[i].x); - mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y); - mb->b_mvs[i].y = (int32_t) ((mv.y == 0) - ? ((TRB - TRD) * last_mb->mvs[i].y) / TRD - : mb->mvs[i].y - last_mb->mvs[i].y); + mb->mvs[i].x = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x; + mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y; + + mb->b_mvs[i].x = (mv.x) + ? mb->mvs[i].x - last_mb->mvs[i].x + : last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp; + mb->b_mvs[i].y = (mv.y) + ? mb->mvs[i].y - last_mb->mvs[i].y + : last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp; } decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], @@ -1361,16 +1373,19 @@ xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, int coding_type, int quant) { + const int brightness = XVID_VERSION_MINOR(frame->version) >= 1 ? frame->brightness : 0; + 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) || 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, brightness, dec->frames, (coding_type == B_VOP)); img = &dec->tmp; } @@ -1544,7 +1559,9 @@ } image_swap(&dec->refn[0], &dec->refn[1]); + dec->is_edged[1] = dec->is_edged[0]; image_swap(&dec->cur, &dec->refn[0]); + dec->is_edged[0] = 0; SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs); dec->last_reduced_resolution = reduced_resolution; dec->last_coding_type = coding_type;