68 |
|
|
69 |
#include "xvid.h" |
#include "xvid.h" |
70 |
#include "portab.h" |
#include "portab.h" |
71 |
|
#include "global.h" |
72 |
|
|
73 |
#include "decoder.h" |
#include "decoder.h" |
74 |
#include "bitstream/bitstream.h" |
#include "bitstream/bitstream.h" |
385 |
|
|
386 |
|
|
387 |
|
|
|
|
|
|
#define SIGN(X) (((X)>0)?1:-1) |
|
|
#define ABS(X) (((X)>0)?(X):-(X)) |
|
|
|
|
388 |
// decode an inter macroblock |
// decode an inter macroblock |
389 |
|
|
390 |
void |
void |
675 |
|
|
676 |
if (dec->interlacing) { |
if (dec->interlacing) { |
677 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
678 |
DEBUG1("deci: field_dct: ", mb->field_dct); |
DPRINTF(DPRINTF_MB,"deci: field_dct: %i", mb->field_dct); |
679 |
} |
} |
680 |
|
|
681 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
853 |
if (dec->interlacing) { |
if (dec->interlacing) { |
854 |
if (cbp || intra) { |
if (cbp || intra) { |
855 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
856 |
DEBUG1("decp: field_dct: ", mb->field_dct); |
DPRINTF(DPRINTF_MB,"decp: field_dct: %i", mb->field_dct); |
857 |
} |
} |
858 |
|
|
859 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
860 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
861 |
DEBUG1("decp: field_pred: ", mb->field_pred); |
DPRINTF(DPRINTF_MB, "decp: field_pred: %i", mb->field_pred); |
862 |
|
|
863 |
if (mb->field_pred) { |
if (mb->field_pred) { |
864 |
mb->field_for_top = BitstreamGetBit(bs); |
mb->field_for_top = BitstreamGetBit(bs); |
865 |
DEBUG1("decp: field_for_top: ", mb->field_for_top); |
DPRINTF(DPRINTF_MB,"decp: field_for_top: %i", mb->field_for_top); |
866 |
mb->field_for_bot = BitstreamGetBit(bs); |
mb->field_for_bot = BitstreamGetBit(bs); |
867 |
DEBUG1("decp: field_for_bot: ", mb->field_for_bot); |
DPRINTF(DPRINTF_MB,"decp: field_for_bot: %i", mb->field_for_bot); |
868 |
} |
} |
869 |
} |
} |
870 |
} |
} |
912 |
} |
} |
913 |
else if (gmc_mv) /* not coded S_VOP macroblock */ |
else if (gmc_mv) /* not coded S_VOP macroblock */ |
914 |
{ |
{ |
915 |
mb->mode = MODE_NOT_CODED; |
mb->mode = MODE_NOT_CODED_GMC; |
916 |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode); |
mb->mvs[0].x = mb->mvs[1].x = mb->mvs[2].x = mb->mvs[3].x = gmc_sanitize(gmc_mv[0].x, dec->quarterpel, fcode); |
917 |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode); |
mb->mvs[0].y = mb->mvs[1].y = mb->mvs[2].y = mb->mvs[3].y = gmc_sanitize(gmc_mv[0].y, dec->quarterpel, fcode); |
918 |
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution); |
decoder_mbinter(dec, mb, x, y, 0, 0, bs, quant, rounding, reduced_resolution); |
1464 |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
mb->b_mvs[0] = mb->b_mvs[1] = mb->b_mvs[2] = mb->b_mvs[3] = |
1465 |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
mb->mvs[0] = mb->mvs[1] = mb->mvs[2] = mb->mvs[3] = zeromv; |
1466 |
|
|
1467 |
// the last P_VOP is skip macroblock ? |
// skip if the co-located P_VOP macroblock is not coded |
1468 |
|
// note: gmc+not_coded isn't skipped |
1469 |
|
|
1470 |
if (last_mb->mode == MODE_NOT_CODED) { |
if (last_mb->mode == MODE_NOT_CODED) { |
1471 |
//DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); |
//DEBUG2("Skip MB in B-frame at (X,Y)=!",x,y); |
1472 |
mb->cbp = 0; |
mb->cbp = 0; |
1580 |
break; |
break; |
1581 |
|
|
1582 |
default: |
default: |
1583 |
DEBUG1("Not support B-frame mb_type =", mb->mb_type); |
DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type); |
1584 |
} |
} |
1585 |
|
|
1586 |
} // end of FOR |
} // end of FOR |
1650 |
dec->low_delay_default = (frame->general & XVID_DEC_LOWDELAY); |
dec->low_delay_default = (frame->general & XVID_DEC_LOWDELAY); |
1651 |
dec->out_frm = (frame->colorspace == XVID_CSP_EXTERN) ? frame->image : NULL; |
dec->out_frm = (frame->colorspace == XVID_CSP_EXTERN) ? frame->image : NULL; |
1652 |
|
|
1653 |
|
if ((frame->general & XVID_DEC_DISCONTINUITY)) |
1654 |
|
dec->frames = 0; |
1655 |
|
|
1656 |
if (frame->length < 0) /* decoder flush */ |
if (frame->length < 0) /* decoder flush */ |
1657 |
{ |
{ |
1658 |
/* 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 |
1702 |
if (vop_type == - 1) |
if (vop_type == - 1) |
1703 |
{ |
{ |
1704 |
if (success) goto done; |
if (success) goto done; |
1705 |
|
emms(); |
1706 |
return XVID_ERR_FAIL; |
return XVID_ERR_FAIL; |
1707 |
} |
} |
1708 |
|
|
1723 |
stats->data.vol.par_width = dec->par_width; |
stats->data.vol.par_width = dec->par_width; |
1724 |
stats->data.vol.par_height = dec->par_height; |
stats->data.vol.par_height = dec->par_height; |
1725 |
frame->length = BitstreamPos(&bs) / 8; |
frame->length = BitstreamPos(&bs) / 8; |
1726 |
|
emms(); |
1727 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
1728 |
} |
} |
1729 |
goto repeat; |
goto repeat; |
1839 |
{ |
{ |
1840 |
/* output the recently decoded frame */ |
/* output the recently decoded frame */ |
1841 |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, dec->last_reduced_resolution); |
decoder_output(dec, &dec->refn[0], dec->last_mbs, frame, dec->last_reduced_resolution); |
1842 |
|
output = 1; |
1843 |
} |
} |
1844 |
else |
else |
1845 |
{ |
{ |
1851 |
|
|
1852 |
decoder_output(dec, &dec->cur, NULL, frame, 1 /*disable pp*/); |
decoder_output(dec, &dec->cur, NULL, frame, 1 /*disable pp*/); |
1853 |
} |
} |
|
output = 1; |
|
1854 |
} |
} |
1855 |
|
|
1856 |
frame->length = BitstreamPos(&bs) / 8; |
frame->length = BitstreamPos(&bs) / 8; |