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; |
|
dec->time_inc_resolution = 1; /* until VOL header says otherwise */ |
|
225 |
|
|
226 |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
dec->fixed_dimensions = (dec->width > 0 && dec->height > 0); |
227 |
|
|
338 |
stop_coding_timer(); |
stop_coding_timer(); |
339 |
|
|
340 |
start_timer(); |
start_timer(); |
341 |
add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors, dec->bs_version); |
add_acdc(pMB, i, &block[i * 64], iDcScaler, predictors); |
342 |
stop_prediction_timer(); |
stop_prediction_timer(); |
343 |
|
|
344 |
start_timer(); |
start_timer(); |
1139 |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
interpolate8x8_avg2(dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1140 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos, |
1141 |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos, |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos, |
1142 |
stride, 0, 8); |
stride, 1, 8); |
1143 |
|
|
1144 |
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, |
1145 |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->cur.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1146 |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
dec->tmp.y + (16 * y_pos * stride) + 16 * x_pos + 8, |
1147 |
stride, 0, 8); |
stride, 1, 8); |
1148 |
|
|
1149 |
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, |
1150 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1151 |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos, |
1152 |
stride, 0, 8); |
stride, 1, 8); |
1153 |
|
|
1154 |
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, |
1155 |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->cur.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1156 |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
dec->tmp.y + ((16 * y_pos + 8) * stride) + 16 * x_pos + 8, |
1157 |
stride, 0, 8); |
stride, 1, 8); |
1158 |
|
|
1159 |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1160 |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.u + (8 * y_pos * stride2) + 8 * x_pos, |
1161 |
dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos, |
dec->tmp.u + (8 * y_pos * stride2) + 8 * x_pos, |
1162 |
stride2, 0, 8); |
stride2, 1, 8); |
1163 |
|
|
1164 |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
interpolate8x8_avg2(dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1165 |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->cur.v + (8 * y_pos * stride2) + 8 * x_pos, |
1166 |
dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos, |
dec->tmp.v + (8 * y_pos * stride2) + 8 * x_pos, |
1167 |
stride2, 0, 8); |
stride2, 1, 8); |
1168 |
|
|
1169 |
stop_comp_timer(); |
stop_comp_timer(); |
1170 |
|
|
1214 |
uint32_t x, y; |
uint32_t x, y; |
1215 |
VECTOR mv; |
VECTOR mv; |
1216 |
const VECTOR zeromv = {0,0}; |
const VECTOR zeromv = {0,0}; |
1217 |
|
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 = last_mb->mvs[i].x*dec->time_bp/dec->time_pp + mv.x; |
mb->mvs[i].x = (int32_t) ((TRB * last_mb->mvs[i].x) / TRD + mv.x); |
1313 |
mb->mvs[i].y = last_mb->mvs[i].y*dec->time_bp/dec->time_pp + mv.y; |
mb->b_mvs[i].x = (int32_t) ((mv.x == 0) |
1314 |
|
? ((TRB - TRD) * last_mb->mvs[i].x) / TRD |
1315 |
mb->b_mvs[i].x = (mv.x) |
: mb->mvs[i].x - last_mb->mvs[i].x); |
1316 |
? mb->mvs[i].x - last_mb->mvs[i].x |
mb->mvs[i].y = (int32_t) ((TRB * last_mb->mvs[i].y) / TRD + mv.y); |
1317 |
: last_mb->mvs[i].x*(dec->time_bp - dec->time_pp)/dec->time_pp; |
mb->b_mvs[i].y = (int32_t) ((mv.y == 0) |
1318 |
mb->b_mvs[i].y = (mv.y) |
? ((TRB - TRD) * last_mb->mvs[i].y) / TRD |
1319 |
? mb->mvs[i].y - last_mb->mvs[i].y |
: mb->mvs[i].y - last_mb->mvs[i].y); |
|
: last_mb->mvs[i].y*(dec->time_bp - dec->time_pp)/dec->time_pp; |
|
1320 |
} |
} |
1321 |
|
|
1322 |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
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 |
|
|
1492 |
goto repeat; |
goto repeat; |
1493 |
} |
} |
1494 |
|
|
|
if(dec->frames == 0 && coding_type != I_VOP) { |
|
|
/* 1st frame is not an i-vop */ |
|
|
goto repeat; |
|
|
} |
|
|
|
|
1495 |
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 */ |
1496 |
|
|
1497 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |
1553 |
|
|
1554 |
if (dec->low_delay) { |
if (dec->low_delay) { |
1555 |
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"); |
1556 |
dec->low_delay = 0; |
dec->low_delay = 1; |
1557 |
} |
} |
1558 |
|
|
1559 |
if (dec->frames < 2) { |
if (dec->frames < 2) { |