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 |
77 |
xvid_free(dec->last_mbs); |
xvid_free(dec->last_mbs); |
78 |
if (dec->mbs) |
if (dec->mbs) |
79 |
xvid_free(dec->mbs); |
xvid_free(dec->mbs); |
80 |
|
if (dec->qscale) |
81 |
|
xvid_free(dec->qscale); |
82 |
|
|
83 |
/* realloc */ |
/* realloc */ |
84 |
dec->mb_width = (dec->width + 15) / 16; |
dec->mb_width = (dec->width + 15) / 16; |
163 |
|
|
164 |
memset(dec->last_mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
memset(dec->last_mbs, 0, sizeof(MACROBLOCK) * dec->mb_width * dec->mb_height); |
165 |
|
|
166 |
|
/* nothing happens if that fails */ |
167 |
|
dec->qscale = |
168 |
|
xvid_malloc(sizeof(int) * dec->mb_width * dec->mb_height, CACHE_LINE); |
169 |
|
|
170 |
|
if (dec->qscale) |
171 |
|
memset(dec->qscale, 0, sizeof(int) * dec->mb_width * dec->mb_height); |
172 |
|
|
173 |
return 0; |
return 0; |
174 |
} |
} |
175 |
|
|
209 |
/* image based GMC */ |
/* image based GMC */ |
210 |
image_null(&dec->gmc); |
image_null(&dec->gmc); |
211 |
|
|
|
|
|
212 |
dec->mbs = NULL; |
dec->mbs = NULL; |
213 |
dec->last_mbs = NULL; |
dec->last_mbs = NULL; |
214 |
|
dec->qscale = NULL; |
215 |
|
|
216 |
init_timer(); |
init_timer(); |
217 |
init_postproc(); |
init_postproc(&dec->postproc); |
218 |
init_mpeg_matrix(dec->mpeg_quant_matrices); |
init_mpeg_matrix(dec->mpeg_quant_matrices); |
219 |
|
|
220 |
/* For B-frame support (used to save reference frame's time */ |
/* For B-frame support (used to save reference frame's time */ |
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 |
|
|
238 |
{ |
{ |
239 |
xvid_free(dec->last_mbs); |
xvid_free(dec->last_mbs); |
240 |
xvid_free(dec->mbs); |
xvid_free(dec->mbs); |
241 |
|
xvid_free(dec->qscale); |
242 |
|
|
243 |
/* image based GMC */ |
/* image based GMC */ |
244 |
image_destroy(&dec->gmc, dec->edged_width, dec->edged_height); |
image_destroy(&dec->gmc, dec->edged_width, dec->edged_height); |
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 */ |
817 |
|
|
818 |
start_timer(); |
start_timer(); |
819 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
820 |
dec->width, dec->height); |
dec->width, dec->height, dec->bs_version); |
821 |
stop_edges_timer(); |
stop_edges_timer(); |
822 |
|
|
823 |
if (gmc_warp) { |
if (gmc_warp) { |
889 |
mb->quant = quant; |
mb->quant = quant; |
890 |
|
|
891 |
if (dec->interlacing) { |
if (dec->interlacing) { |
892 |
if ((cbp || intra) && !mcsel) { |
if (cbp || intra) { |
893 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
894 |
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
895 |
} |
} |
896 |
|
|
897 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if ((mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) && !mcsel) { |
898 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
899 |
DPRINTF(XVID_DEBUG_MB, "decp: field_pred: %i\n", mb->field_pred); |
DPRINTF(XVID_DEBUG_MB, "decp: field_pred: %i\n", mb->field_pred); |
900 |
|
|
938 |
|
|
939 |
} else if (gmc_warp) { /* a not coded S(GMC)-VOP macroblock */ |
} else if (gmc_warp) { /* a not coded S(GMC)-VOP macroblock */ |
940 |
mb->mode = MODE_NOT_CODED_GMC; |
mb->mode = MODE_NOT_CODED_GMC; |
941 |
|
mb->quant = quant; |
942 |
decoder_mbgmc(dec, mb, x, y, fcode, 0x00, bs, rounding); |
decoder_mbgmc(dec, mb, x, y, fcode, 0x00, bs, rounding); |
943 |
|
|
944 |
if(dec->out_frm && cp_mb > 0) { |
if(dec->out_frm && cp_mb > 0) { |
948 |
st_mb = x+1; |
st_mb = x+1; |
949 |
} else { /* not coded P_VOP macroblock */ |
} else { /* not coded P_VOP macroblock */ |
950 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED; |
951 |
|
mb->quant = quant; |
952 |
|
|
953 |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = 0; |
954 |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = 0; |
975 |
get_b_motion_vector(Bitstream * bs, |
get_b_motion_vector(Bitstream * bs, |
976 |
VECTOR * mv, |
VECTOR * mv, |
977 |
int fcode, |
int fcode, |
978 |
const VECTOR pmv) |
const VECTOR pmv, |
979 |
|
const DECODER * const dec, |
980 |
|
const int x, const int y) |
981 |
{ |
{ |
982 |
const int scale_fac = 1 << (fcode - 1); |
const int scale_fac = 1 << (fcode - 1); |
983 |
const int high = (32 * scale_fac) - 1; |
const int high = (32 * scale_fac) - 1; |
1092 |
pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
pMB->mvs[1].x, pMB->mvs[1].y, stride, 0); |
1093 |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos, 16 * y_pos + 8, |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos, 16 * y_pos + 8, |
1094 |
pMB->mvs[2].x, pMB->mvs[2].y, stride, 0); |
pMB->mvs[2].x, pMB->mvs[2].y, stride, 0); |
1095 |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, |
interpolate8x8_switch(dec->cur.y, forward.y, 16 * x_pos + 8, 16 * y_pos + 8, |
1096 |
16 * y_pos + 8, pMB->mvs[3].x, pMB->mvs[3].y, stride, 0); |
pMB->mvs[3].x, pMB->mvs[3].y, stride, 0); |
1097 |
} |
} |
1098 |
|
|
1099 |
interpolate8x8_switch(dec->cur.u, forward.u, 8 * x_pos, 8 * y_pos, uv_dx, |
interpolate8x8_switch(dec->cur.u, forward.u, 8 * x_pos, 8 * y_pos, uv_dx, |
1220 |
|
|
1221 |
start_timer(); |
start_timer(); |
1222 |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[0], dec->edged_width, dec->edged_height, |
1223 |
dec->width, dec->height); |
dec->width, dec->height, dec->bs_version); |
1224 |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
image_setedges(&dec->refn[1], dec->edged_width, dec->edged_height, |
1225 |
dec->width, dec->height); |
dec->width, dec->height, dec->bs_version); |
1226 |
stop_edges_timer(); |
stop_edges_timer(); |
1227 |
|
|
1228 |
for (y = 0; y < dec->mb_height; y++) { |
for (y = 0; y < dec->mb_height; y++) { |
1306 |
|
|
1307 |
switch (mb->mode) { |
switch (mb->mode) { |
1308 |
case MODE_DIRECT: |
case MODE_DIRECT: |
1309 |
get_b_motion_vector(bs, &mv, 1, zeromv); |
get_b_motion_vector(bs, &mv, 1, zeromv, dec, x, y); |
1310 |
|
|
1311 |
case MODE_DIRECT_NONE_MV: |
case MODE_DIRECT_NONE_MV: |
1312 |
for (i = 0; i < 4; i++) { |
for (i = 0; i < 4; i++) { |
1325 |
break; |
break; |
1326 |
|
|
1327 |
case MODE_INTERPOLATE: |
case MODE_INTERPOLATE: |
1328 |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv); |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y); |
1329 |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1330 |
|
|
1331 |
get_b_motion_vector(bs, &mb->b_mvs[0], fcode_backward, dec->p_bmv); |
get_b_motion_vector(bs, &mb->b_mvs[0], fcode_backward, dec->p_bmv, dec, x, y); |
1332 |
dec->p_bmv = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = mb->b_mvs[0]; |
dec->p_bmv = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = mb->b_mvs[0]; |
1333 |
|
|
1334 |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
decoder_bf_interpolate_mbinter(dec, dec->refn[1], dec->refn[0], |
1336 |
break; |
break; |
1337 |
|
|
1338 |
case MODE_BACKWARD: |
case MODE_BACKWARD: |
1339 |
get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv); |
get_b_motion_vector(bs, &mb->mvs[0], fcode_backward, dec->p_bmv, dec, x, y); |
1340 |
dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
dec->p_bmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1341 |
|
|
1342 |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 0); |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 0); |
1343 |
break; |
break; |
1344 |
|
|
1345 |
case MODE_FORWARD: |
case MODE_FORWARD: |
1346 |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv); |
get_b_motion_vector(bs, &mb->mvs[0], fcode_forward, dec->p_fmv, dec, x, y); |
1347 |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
dec->p_fmv = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = mb->mvs[0]; |
1348 |
|
|
1349 |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1); |
decoder_mbinter(dec, mb, x, y, mb->cbp, bs, 0, 0, 1); |
1358 |
|
|
1359 |
/* perform post processing if necessary, and output the image */ |
/* perform post processing if necessary, and output the image */ |
1360 |
void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs, |
void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs, |
1361 |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, int coding_type) |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, |
1362 |
|
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->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); |
frame->general, brightness, dec->frames, (coding_type == B_VOP)); |
1377 |
img = &dec->tmp; |
img = &dec->tmp; |
1378 |
} |
} |
1379 |
|
|
1385 |
stats->type = coding2type(coding_type); |
stats->type = coding2type(coding_type); |
1386 |
stats->data.vop.time_base = (int)dec->time_base; |
stats->data.vop.time_base = (int)dec->time_base; |
1387 |
stats->data.vop.time_increment = 0; /* XXX: todo */ |
stats->data.vop.time_increment = 0; /* XXX: todo */ |
1388 |
|
stats->data.vop.qscale_stride = dec->mb_width; |
1389 |
|
stats->data.vop.qscale = dec->qscale; |
1390 |
|
if (stats->data.vop.qscale != NULL && mbs != NULL) { |
1391 |
|
int i; |
1392 |
|
for (i = 0; i < dec->mb_width*dec->mb_height; i++) |
1393 |
|
stats->data.vop.qscale[i] = mbs[i].quant; |
1394 |
|
} else |
1395 |
|
stats->data.vop.qscale = NULL; |
1396 |
} |
} |
1397 |
} |
} |
1398 |
|
|
1405 |
Bitstream bs; |
Bitstream bs; |
1406 |
uint32_t rounding; |
uint32_t rounding; |
1407 |
uint32_t reduced_resolution; |
uint32_t reduced_resolution; |
1408 |
uint32_t quant; |
uint32_t quant = 2; |
1409 |
uint32_t fcode_forward; |
uint32_t fcode_forward; |
1410 |
uint32_t fcode_backward; |
uint32_t fcode_backward; |
1411 |
uint32_t intra_dc_threshold; |
uint32_t intra_dc_threshold; |
1428 |
/* if not decoding "low_delay/packed", and this isn't low_delay and |
/* if not decoding "low_delay/packed", and this isn't low_delay and |
1429 |
we have a reference frame, then outout the reference frame */ |
we have a reference frame, then outout the reference frame */ |
1430 |
if (!(dec->low_delay_default && dec->packed_mode) && !dec->low_delay && dec->frames>0) { |
if (!(dec->low_delay_default && dec->packed_mode) && !dec->low_delay && dec->frames>0) { |
1431 |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type); |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant); |
1432 |
dec->frames = 0; |
dec->frames = 0; |
1433 |
ret = 0; |
ret = 0; |
1434 |
} else { |
} else { |
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 */ |
1504 |
if (dec->packed_mode && coding_type == N_VOP) { |
if (dec->packed_mode && coding_type == N_VOP) { |
1505 |
if (dec->low_delay_default && dec->frames > 0) { |
if (dec->low_delay_default && dec->frames > 0) { |
1506 |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type); |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant); |
1507 |
output = 1; |
output = 1; |
1508 |
} |
} |
1509 |
/* ignore otherwise */ |
/* ignore otherwise */ |
1537 |
/* note: for packed_mode, output is performed when the special-N_VOP is decoded */ |
/* note: for packed_mode, output is performed when the special-N_VOP is decoded */ |
1538 |
if (!(dec->low_delay_default && dec->packed_mode)) { |
if (!(dec->low_delay_default && dec->packed_mode)) { |
1539 |
if (dec->low_delay) { |
if (dec->low_delay) { |
1540 |
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type, quant); |
1541 |
output = 1; |
output = 1; |
1542 |
} else if (dec->frames > 0) { /* is the reference frame valid? */ |
} else if (dec->frames > 0) { /* is the reference frame valid? */ |
1543 |
/* output the reference frame */ |
/* output the reference frame */ |
1544 |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type); |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant); |
1545 |
output = 1; |
output = 1; |
1546 |
} |
} |
1547 |
} |
} |
1566 |
/* attemping to decode a bvop without atleast 2 reference frames */ |
/* attemping to decode a bvop without atleast 2 reference frames */ |
1567 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1568 |
"broken b-frame, mising ref frames"); |
"broken b-frame, mising ref frames"); |
1569 |
stats->type = XVID_TYPE_NOTHING; |
if (stats) stats->type = XVID_TYPE_NOTHING; |
1570 |
} else if (dec->time_pp <= dec->time_bp) { |
} else if (dec->time_pp <= dec->time_bp) { |
1571 |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
1572 |
decoded in vfw. */ |
decoded in vfw. */ |
1573 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1574 |
"broken b-frame, tpp=%i tbp=%i", dec->time_pp, dec->time_bp); |
"broken b-frame, tpp=%i tbp=%i", dec->time_pp, dec->time_bp); |
1575 |
stats->type = XVID_TYPE_NOTHING; |
if (stats) stats->type = XVID_TYPE_NOTHING; |
1576 |
} else { |
} else { |
1577 |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
1578 |
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type, quant); |
1579 |
} |
} |
1580 |
|
|
1581 |
output = 1; |
output = 1; |
1582 |
dec->frames++; |
dec->frames++; |
1583 |
} |
} |
1584 |
|
|
1585 |
|
#if 0 /* Avoids to read to much data because of 32bit reads in our BS functions */ |
1586 |
BitstreamByteAlign(&bs); |
BitstreamByteAlign(&bs); |
1587 |
|
#endif |
1588 |
|
|
1589 |
/* low_delay_default mode: repeat in packed_mode */ |
/* low_delay_default mode: repeat in packed_mode */ |
1590 |
if (dec->low_delay_default && dec->packed_mode && output == 0 && success == 0) { |
if (dec->low_delay_default && dec->packed_mode && output == 0 && success == 0) { |
1599 |
if (dec->low_delay_default && output == 0) { |
if (dec->low_delay_default && output == 0) { |
1600 |
if (dec->packed_mode && seen_something) { |
if (dec->packed_mode && seen_something) { |
1601 |
/* output the recently decoded frame */ |
/* output the recently decoded frame */ |
1602 |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type); |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, stats, dec->last_coding_type, quant); |
1603 |
} else { |
} else { |
1604 |
image_clear(&dec->cur, dec->width, dec->height, dec->edged_width, 0, 128, 128); |
image_clear(&dec->cur, dec->width, dec->height, dec->edged_width, 0, 128, 128); |
1605 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1607 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 64, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 64, |
1608 |
"bframe decoder lag"); |
"bframe decoder lag"); |
1609 |
|
|
1610 |
decoder_output(dec, &dec->cur, NULL, frame, stats, P_VOP); |
decoder_output(dec, &dec->cur, NULL, frame, stats, P_VOP, quant); |
1611 |
if (stats) stats->type = XVID_TYPE_NOTHING; |
if (stats) stats->type = XVID_TYPE_NOTHING; |
1612 |
} |
} |
1613 |
} |
} |
1615 |
emms(); |
emms(); |
1616 |
stop_global_timer(); |
stop_global_timer(); |
1617 |
|
|
1618 |
return BitstreamPos(&bs) / 8; /* number of bytes consumed */ |
return (BitstreamPos(&bs) + 7) / 8; /* number of bytes consumed */ |
1619 |
} |
} |