20 |
* along with this program ; if not, write to the Free Software |
* along with this program ; if not, write to the Free Software |
21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
22 |
* |
* |
23 |
* $Id: decoder.c,v 1.49.2.20 2003-11-30 16:13:15 edgomez Exp $ |
* $Id: decoder.c,v 1.49.2.26 2003-12-17 17:07:38 Isibaar Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
58 |
|
|
59 |
#include "image/image.h" |
#include "image/image.h" |
60 |
#include "image/colorspace.h" |
#include "image/colorspace.h" |
61 |
|
#include "image/postprocessing.h" |
62 |
#include "utils/mem_align.h" |
#include "utils/mem_align.h" |
63 |
|
|
64 |
static int |
static int |
205 |
dec->last_mbs = NULL; |
dec->last_mbs = NULL; |
206 |
|
|
207 |
init_timer(); |
init_timer(); |
208 |
|
init_postproc(); |
209 |
init_mpeg_matrix(dec->mpeg_quant_matrices); |
init_mpeg_matrix(dec->mpeg_quant_matrices); |
210 |
|
|
211 |
/* For B-frame support (used to save reference frame's time */ |
/* For B-frame support (used to save reference frame's time */ |
1318 |
void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs, |
void decoder_output(DECODER * dec, IMAGE * img, MACROBLOCK * mbs, |
1319 |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, int coding_type) |
xvid_dec_frame_t * frame, xvid_dec_stats_t * stats, int coding_type) |
1320 |
{ |
{ |
1321 |
|
if (frame->general & (XVID_DEBLOCKY|XVID_DEBLOCKUV) && mbs != NULL) /* post process */ |
1322 |
|
{ |
1323 |
|
/* note: image is stored to tmp */ |
1324 |
|
image_copy(&dec->tmp, img, dec->edged_width, dec->height); |
1325 |
|
image_postproc(&dec->tmp, dec->edged_width, |
1326 |
|
mbs, dec->mb_width, dec->mb_height, dec->mb_width, |
1327 |
|
frame->general, dec->frames); |
1328 |
|
img = &dec->tmp; |
1329 |
|
} |
1330 |
|
|
1331 |
image_output(img, dec->width, dec->height, |
image_output(img, dec->width, dec->height, |
1332 |
dec->edged_width, (uint8_t**)frame->output.plane, frame->output.stride, |
dec->edged_width, (uint8_t**)frame->output.plane, frame->output.stride, |
1333 |
frame->output.csp, dec->interlacing); |
frame->output.csp, dec->interlacing); |
1462 |
/* XXX: not_coded vops are not used for forward prediction */ |
/* XXX: not_coded vops are not used for forward prediction */ |
1463 |
/* we should not swap(last_mbs,mbs) */ |
/* we should not swap(last_mbs,mbs) */ |
1464 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1465 |
|
SWAP(MACROBLOCK *, dec->mbs, dec->last_mbs); /* it will be swapped back */ |
1466 |
break; |
break; |
1467 |
} |
} |
1468 |
|
|
1504 |
/* attemping to decode a bvop without atleast 2 reference frames */ |
/* attemping to decode a bvop without atleast 2 reference frames */ |
1505 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1506 |
"broken b-frame, mising ref frames"); |
"broken b-frame, mising ref frames"); |
1507 |
|
stats->type = XVID_TYPE_NOTHING; |
1508 |
} else if (dec->time_pp <= dec->time_bp) { |
} else if (dec->time_pp <= dec->time_bp) { |
1509 |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
/* this occurs when dx50_bvop_compatibility==0 sequences are |
1510 |
decoded in vfw. */ |
decoded in vfw. */ |
1511 |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
image_printf(&dec->cur, dec->edged_width, dec->height, 16, 16, |
1512 |
"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); |
1513 |
|
stats->type = XVID_TYPE_NOTHING; |
1514 |
} else { |
} else { |
1515 |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
decoder_bframe(dec, &bs, quant, fcode_forward, fcode_backward); |
1516 |
|
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
1517 |
} |
} |
1518 |
|
|
|
decoder_output(dec, &dec->cur, dec->mbs, frame, stats, coding_type); |
|
1519 |
output = 1; |
output = 1; |
1520 |
dec->frames++; |
dec->frames++; |
1521 |
} |
} |