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.9 2003-06-28 15:48:39 chl Exp $ |
* $Id: decoder.c,v 1.49.2.14 2003-10-03 15:49:21 syskin Exp $ |
24 |
* |
* |
25 |
****************************************************************************/ |
****************************************************************************/ |
26 |
|
|
169 |
{ |
{ |
170 |
DECODER *dec; |
DECODER *dec; |
171 |
|
|
172 |
if (XVID_MAJOR(create->version) != 1) /* v1.x.x */ |
if (XVID_VERSION_MAJOR(create->version) != 1) /* v1.x.x */ |
173 |
return XVID_ERR_VERSION; |
return XVID_ERR_VERSION; |
174 |
|
|
175 |
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
dec = xvid_malloc(sizeof(DECODER), CACHE_LINE); |
915 |
|
|
916 |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
917 |
|
|
|
if (intra) { |
|
|
acpred_flag = BitstreamGetBit(bs); |
|
|
} |
|
|
|
|
918 |
if (gmc_warp && (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)) |
if (gmc_warp && (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q)) |
|
{ |
|
919 |
mcsel = BitstreamGetBit(bs); |
mcsel = BitstreamGetBit(bs); |
920 |
} |
|
921 |
|
if (intra) |
922 |
|
acpred_flag = BitstreamGetBit(bs); |
923 |
|
|
924 |
cbpy = get_cbpy(bs, intra); |
cbpy = get_cbpy(bs, intra); |
925 |
DPRINTF(XVID_DEBUG_MB, "cbpy %i mcsel %i \n", cbpy,mcsel); |
DPRINTF(XVID_DEBUG_MB, "cbpy %i mcsel %i \n", cbpy,mcsel); |
940 |
mb->quant = quant; |
mb->quant = quant; |
941 |
|
|
942 |
if (dec->interlacing) { |
if (dec->interlacing) { |
943 |
if (cbp || intra) { |
if ((cbp || intra) && !mcsel) { |
944 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
945 |
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
946 |
} |
} |
1600 |
quant = 1; |
quant = 1; |
1601 |
} |
} |
1602 |
} |
} |
1603 |
|
|
1604 |
|
if (dec->interlacing) { |
1605 |
|
if (mb->cbp) { |
1606 |
|
mb->field_dct = BitstreamGetBit(bs); |
1607 |
|
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
1608 |
|
} |
1609 |
|
|
1610 |
|
if (mb->mb_type) { |
1611 |
|
mb->field_pred = BitstreamGetBit(bs); |
1612 |
|
DPRINTF(XVID_DEBUG_MB, "decp: field_pred: %i\n", mb->field_pred); |
1613 |
|
|
1614 |
|
if (mb->field_pred) { |
1615 |
|
mb->field_for_top = BitstreamGetBit(bs); |
1616 |
|
DPRINTF(XVID_DEBUG_MB,"decp: field_for_top: %i\n", mb->field_for_top); |
1617 |
|
mb->field_for_bot = BitstreamGetBit(bs); |
1618 |
|
DPRINTF(XVID_DEBUG_MB,"decp: field_for_bot: %i\n", mb->field_for_bot); |
1619 |
|
} |
1620 |
|
} |
1621 |
|
} |
1622 |
|
|
1623 |
} else { |
} else { |
1624 |
mb->mb_type = MODE_DIRECT_NONE_MV; |
mb->mb_type = MODE_DIRECT_NONE_MV; |
1625 |
mb->cbp = 0; |
mb->cbp = 0; |
1748 |
WARPPOINTS gmc_warp; |
WARPPOINTS gmc_warp; |
1749 |
int coding_type; |
int coding_type; |
1750 |
int success, output, seen_something; |
int success, output, seen_something; |
|
idctFuncPtr idct_save; |
|
1751 |
|
|
1752 |
if (XVID_MAJOR(frame->version) != 1 || (stats && XVID_MAJOR(stats->version) != 1)) /* v1.x.x */ |
if (XVID_VERSION_MAJOR(frame->version) != 1 || (stats && XVID_VERSION_MAJOR(stats->version) != 1)) /* v1.x.x */ |
1753 |
return XVID_ERR_VERSION; |
return XVID_ERR_VERSION; |
1754 |
|
|
1755 |
start_global_timer(); |
start_global_timer(); |
1793 |
success = 0; |
success = 0; |
1794 |
output = 0; |
output = 0; |
1795 |
seen_something = 0; |
seen_something = 0; |
|
idct_save = idct; |
|
1796 |
|
|
1797 |
repeat: |
repeat: |
1798 |
|
|
1834 |
|
|
1835 |
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 */ |
1836 |
|
|
|
#if defined(ARCH_IS_IA32) |
|
|
/* |
|
|
* /!\ Ugly hack /!\ |
|
|
* IA32: Prior to xvid bitstream 10, we were using Walten's mmx/xmm idct |
|
|
*/ |
|
|
if((idct == simple_idct_mmx) && (dec->bs_version < 10)) |
|
|
idct = idct_mmx; |
|
|
#endif |
|
|
|
|
1837 |
/* packed_mode: special-N_VOP treament */ |
/* packed_mode: special-N_VOP treament */ |
1838 |
if (dec->packed_mode && coding_type == N_VOP) |
if (dec->packed_mode && coding_type == N_VOP) |
1839 |
{ |
{ |
1962 |
emms(); |
emms(); |
1963 |
stop_global_timer(); |
stop_global_timer(); |
1964 |
|
|
|
idct = idct_save; |
|
|
|
|
1965 |
return BitstreamPos(&bs) / 8; /* number of bytes consumed */ |
return BitstreamPos(&bs) / 8; /* number of bytes consumed */ |
1966 |
} |
} |