304 |
block[i * 64 + 0] = dc_dif; |
block[i * 64 + 0] = dc_dif; |
305 |
start_coeff = 1; |
start_coeff = 1; |
306 |
|
|
307 |
DPRINTF(DPRINTF_COEFF,"block[0] %i", dc_dif); |
DPRINTF(XVID_DEBUG_COEFF,"block[0] %i\n", dc_dif); |
308 |
} else { |
} else { |
309 |
start_coeff = 0; |
start_coeff = 0; |
310 |
} |
} |
737 |
} |
} |
738 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
739 |
|
|
740 |
DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32)); |
DPRINTF(XVID_DEBUG_MB, "macroblock (%i,%i) %08x\n", x, y, BitstreamShowBits(bs, 32)); |
741 |
|
|
742 |
mcbpc = get_mcbpc_intra(bs); |
mcbpc = get_mcbpc_intra(bs); |
743 |
mb->mode = mcbpc & 7; |
mb->mode = mcbpc & 7; |
764 |
|
|
765 |
if (dec->interlacing) { |
if (dec->interlacing) { |
766 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
767 |
DPRINTF(DPRINTF_MB,"deci: field_dct: %i", mb->field_dct); |
DPRINTF(XVID_DEBUG_MB,"deci: field_dct: %i\n", mb->field_dct); |
768 |
} |
} |
769 |
|
|
770 |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
decoder_mbintra(dec, mb, x, y, acpred_flag, cbp, bs, quant, |
802 |
mv.x = get_mv(bs, fcode); |
mv.x = get_mv(bs, fcode); |
803 |
mv.y = get_mv(bs, fcode); |
mv.y = get_mv(bs, fcode); |
804 |
|
|
805 |
DPRINTF(DPRINTF_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)", mv.x, mv.y, pmv.x, pmv.y, mv.x+pmv.x, mv.y+pmv.y); |
DPRINTF(XVID_DEBUG_MV,"mv_diff (%i,%i) pred (%i,%i) result (%i,%i)\n", mv.x, mv.y, pmv.x, pmv.y, mv.x+pmv.x, mv.y+pmv.y); |
806 |
|
|
807 |
mv.x += pmv.x; |
mv.x += pmv.x; |
808 |
mv.y += pmv.y; |
mv.y += pmv.y; |
901 |
} |
} |
902 |
mb = &dec->mbs[y * dec->mb_width + x]; |
mb = &dec->mbs[y * dec->mb_width + x]; |
903 |
|
|
904 |
DPRINTF(DPRINTF_MB, "macroblock (%i,%i) %08x", x, y, BitstreamShowBits(bs, 32)); |
DPRINTF(XVID_DEBUG_MB, "macroblock (%i,%i) %08x\n", x, y, BitstreamShowBits(bs, 32)); |
905 |
|
|
906 |
/* if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs))) */ /* not_coded */ |
/* if (!(dec->mb_skip[y*dec->mb_width + x]=BitstreamGetBit(bs))) */ /* not_coded */ |
907 |
if (!(BitstreamGetBit(bs))) /* block _is_ coded */ |
if (!(BitstreamGetBit(bs))) /* block _is_ coded */ |
919 |
mb->mode = mcbpc & 7; |
mb->mode = mcbpc & 7; |
920 |
cbpc = (mcbpc >> 4); |
cbpc = (mcbpc >> 4); |
921 |
|
|
922 |
DPRINTF(DPRINTF_MB, "mode %i", mb->mode); |
DPRINTF(XVID_DEBUG_MB, "mode %i\n", mb->mode); |
923 |
DPRINTF(DPRINTF_MB, "cbpc %i", cbpc); |
DPRINTF(XVID_DEBUG_MB, "cbpc %i\n", cbpc); |
924 |
acpred_flag = 0; |
acpred_flag = 0; |
925 |
|
|
926 |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
intra = (mb->mode == MODE_INTRA || mb->mode == MODE_INTRA_Q); |
935 |
} |
} |
936 |
|
|
937 |
cbpy = get_cbpy(bs, intra); |
cbpy = get_cbpy(bs, intra); |
938 |
DPRINTF(DPRINTF_MB, "cbpy %i mcsel %i ", cbpy,mcsel); |
DPRINTF(XVID_DEBUG_MB, "cbpy %i mcsel %i \n", cbpy,mcsel); |
939 |
|
|
940 |
cbp = (cbpy << 2) | cbpc; |
cbp = (cbpy << 2) | cbpc; |
941 |
|
|
942 |
if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) { |
if (mb->mode == MODE_INTER_Q || mb->mode == MODE_INTRA_Q) { |
943 |
int dquant = dquant_table[BitstreamGetBits(bs, 2)]; |
int dquant = dquant_table[BitstreamGetBits(bs, 2)]; |
944 |
DPRINTF(DPRINTF_MB, "dquant %i", dquant); |
DPRINTF(XVID_DEBUG_MB, "dquant %i\n", dquant); |
945 |
quant += dquant; |
quant += dquant; |
946 |
if (quant > 31) { |
if (quant > 31) { |
947 |
quant = 31; |
quant = 31; |
948 |
} else if (quant < 1) { |
} else if (quant < 1) { |
949 |
quant = 1; |
quant = 1; |
950 |
} |
} |
951 |
DPRINTF(DPRINTF_MB, "quant %i", quant); |
DPRINTF(XVID_DEBUG_MB, "quant %i\n", quant); |
952 |
} |
} |
953 |
mb->quant = quant; |
mb->quant = quant; |
954 |
|
|
955 |
if (dec->interlacing) { |
if (dec->interlacing) { |
956 |
if (cbp || intra) { |
if (cbp || intra) { |
957 |
mb->field_dct = BitstreamGetBit(bs); |
mb->field_dct = BitstreamGetBit(bs); |
958 |
DPRINTF(DPRINTF_MB,"decp: field_dct: %i", mb->field_dct); |
DPRINTF(XVID_DEBUG_MB,"decp: field_dct: %i\n", mb->field_dct); |
959 |
} |
} |
960 |
|
|
961 |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
if (mb->mode == MODE_INTER || mb->mode == MODE_INTER_Q) { |
962 |
mb->field_pred = BitstreamGetBit(bs); |
mb->field_pred = BitstreamGetBit(bs); |
963 |
DPRINTF(DPRINTF_MB, "decp: field_pred: %i", mb->field_pred); |
DPRINTF(XVID_DEBUG_MB, "decp: field_pred: %i\n", mb->field_pred); |
964 |
|
|
965 |
if (mb->field_pred) { |
if (mb->field_pred) { |
966 |
mb->field_for_top = BitstreamGetBit(bs); |
mb->field_for_top = BitstreamGetBit(bs); |
967 |
DPRINTF(DPRINTF_MB,"decp: field_for_top: %i", mb->field_for_top); |
DPRINTF(XVID_DEBUG_MB,"decp: field_for_top: %i\n", mb->field_for_top); |
968 |
mb->field_for_bot = BitstreamGetBit(bs); |
mb->field_for_bot = BitstreamGetBit(bs); |
969 |
DPRINTF(DPRINTF_MB,"decp: field_for_bot: %i", mb->field_for_bot); |
DPRINTF(XVID_DEBUG_MB,"decp: field_for_bot: %i\n", mb->field_for_bot); |
970 |
} |
} |
971 |
} |
} |
972 |
} |
} |
1691 |
break; |
break; |
1692 |
|
|
1693 |
default: |
default: |
1694 |
DPRINTF(DPRINTF_ERROR,"Not support B-frame mb_type = %i", mb->mb_type); |
DPRINTF(XVID_DEBUG_ERROR,"Not support B-frame mb_type = %i\n", mb->mb_type); |
1695 |
} |
} |
1696 |
} /* End of for */ |
} /* End of for */ |
1697 |
} |
} |
1721 |
{ |
{ |
1722 |
stats->type = coding2type(coding_type); |
stats->type = coding2type(coding_type); |
1723 |
stats->data.vop.time_base = (int)dec->time_base; |
stats->data.vop.time_base = (int)dec->time_base; |
1724 |
stats->data.vop.time_increment = 0; //XXX: todo |
stats->data.vop.time_increment = 0; /* XXX: todo */ |
1725 |
} |
} |
1726 |
} |
} |
1727 |
|
|
1754 |
|
|
1755 |
if (frame->length < 0) /* decoder flush */ |
if (frame->length < 0) /* decoder flush */ |
1756 |
{ |
{ |
1757 |
|
int ret; |
1758 |
/* 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 |
1759 |
we have a reference frame, then outout the reference frame */ |
we have a reference frame, then outout the reference frame */ |
1760 |
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) { |
|
{ |
|
1761 |
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); |
1762 |
|
dec->frames = 0; |
1763 |
|
ret = 0; |
1764 |
}else{ |
}else{ |
1765 |
if (stats) stats->type = XVID_TYPE_NOTHING; |
if (stats) stats->type = XVID_TYPE_NOTHING; |
1766 |
|
ret = XVID_ERR_END; |
1767 |
} |
} |
1768 |
|
|
1769 |
emms(); |
emms(); |
1770 |
stop_global_timer(); |
stop_global_timer(); |
1771 |
return 0; |
return ret; |
1772 |
} |
} |
1773 |
|
|
1774 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1792 |
coding_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
coding_type = BitstreamReadHeaders(&bs, dec, &rounding, &reduced_resolution, |
1793 |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp); |
&quant, &fcode_forward, &fcode_backward, &intra_dc_threshold, &gmc_warp); |
1794 |
|
|
1795 |
DPRINTF(DPRINTF_HEADER, "coding_type=%i, packed=%i, time=%lli, time_pp=%i, time_bp=%i", |
DPRINTF(XVID_DEBUG_HEADER, "coding_type=%i, packed=%i, time=%lli, time_pp=%i, time_bp=%i\n", |
1796 |
coding_type, dec->packed_mode, dec->time, dec->time_pp, dec->time_bp); |
coding_type, dec->packed_mode, dec->time, dec->time_pp, dec->time_bp); |
1797 |
|
|
1798 |
if (coding_type == -1) /* nothing */ |
if (coding_type == -1) /* nothing */ |
1854 |
fcode_forward, intra_dc_threshold, &gmc_warp); |
fcode_forward, intra_dc_threshold, &gmc_warp); |
1855 |
break; |
break; |
1856 |
case N_VOP : |
case N_VOP : |
1857 |
// XXX: not_coded vops are not used for forward prediction |
/* XXX: not_coded vops are not used for forward prediction */ |
1858 |
// we should not swap(last_mbs,mbs) |
/* we should not swap(last_mbs,mbs) */ |
1859 |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
image_copy(&dec->cur, &dec->refn[0], dec->edged_width, dec->height); |
1860 |
break; |
break; |
1861 |
} |
} |
1896 |
|
|
1897 |
if (dec->low_delay) |
if (dec->low_delay) |
1898 |
{ |
{ |
1899 |
DPRINTF(DPRINTF_ERROR, "warning: bvop found in low_delay==1 stream"); |
DPRINTF(XVID_DEBUG_ERROR, "warning: bvop found in low_delay==1 stream\n"); |
1900 |
dec->low_delay = 1; |
dec->low_delay = 1; |
1901 |
} |
} |
1902 |
|
|