55 |
* 22.12.2001 lock based interpolation |
* 22.12.2001 lock based interpolation |
56 |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
* 01.12.2001 inital version; (c)2001 peter ross <pross@cs.rmit.edu.au> |
57 |
* |
* |
58 |
* $Id: decoder.c,v 1.37.2.8 2002-11-07 10:28:15 suxen_drol Exp $ |
* $Id: decoder.c,v 1.37.2.12 2002-11-19 13:21:24 suxen_drol Exp $ |
59 |
* |
* |
60 |
*************************************************************************/ |
*************************************************************************/ |
61 |
|
|
1463 |
uint32_t intra_dc_threshold; |
uint32_t intra_dc_threshold; |
1464 |
VECTOR gmc_mv[5]; |
VECTOR gmc_mv[5]; |
1465 |
uint32_t vop_type; |
uint32_t vop_type; |
1466 |
|
int success = 0; |
1467 |
|
|
1468 |
start_global_timer(); |
start_global_timer(); |
1469 |
|
|
1471 |
|
|
1472 |
BitstreamInit(&bs, frame->bitstream, frame->length); |
BitstreamInit(&bs, frame->bitstream, frame->length); |
1473 |
|
|
|
#ifdef BFRAMES_DEC |
|
1474 |
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
// XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's |
1475 |
if(BitstreamShowBits(&bs, 8) == 0x7f) |
if(frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f) |
1476 |
{ |
{ |
1477 |
if (stats) |
if (stats) |
1478 |
stats->notify = XVID_DEC_VOP; |
stats->notify = XVID_DEC_VOP; |
1479 |
frame->length = 1; |
frame->length = 1; |
1480 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->refn[0], dec->width, dec->height, dec->edged_width, |
1481 |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
1482 |
|
emms(); |
1483 |
return XVID_ERR_OK; |
return XVID_ERR_OK; |
1484 |
} |
} |
|
#endif |
|
1485 |
|
|
1486 |
|
start: |
1487 |
// add by chenm001 <chenm001@163.com> |
// add by chenm001 <chenm001@163.com> |
1488 |
// for support B-frame to reference last 2 frame |
// for support B-frame to reference last 2 frame |
1489 |
dec->frames++; |
dec->frames++; |
1495 |
|
|
1496 |
DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); |
DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); |
1497 |
|
|
1498 |
|
if (vop_type == -1 && success) |
1499 |
|
goto done; |
1500 |
|
|
1501 |
if (vop_type == -2 || vop_type == -3) |
if (vop_type == -2 || vop_type == -3) |
1502 |
{ |
{ |
1503 |
if (vop_type == -3) |
if (vop_type == -3) |
1567 |
default: |
default: |
1568 |
if (stats) |
if (stats) |
1569 |
stats->notify = 0; |
stats->notify = 0; |
|
return XVID_ERR_FAIL; |
|
|
} |
|
1570 |
|
|
1571 |
#ifdef BFRAMES_DEC_DEBUG |
emms(); |
1572 |
if (frame->length != BitstreamPos(&bs) / 8){ |
return XVID_ERR_FAIL; |
|
DEBUG2("InLen/UseLen",frame->length, BitstreamPos(&bs) / 8); |
|
1573 |
} |
} |
|
#endif |
|
|
frame->length = BitstreamPos(&bs) / 8; |
|
1574 |
|
|
1575 |
|
BitstreamByteAlign(&bs); |
1576 |
|
|
1577 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1578 |
// test if no B_VOP |
// test if no B_VOP |
1579 |
if (dec->low_delay || dec->frames == 0) { |
if (dec->low_delay || dec->frames == 0 || ((dec->packed_mode) && !(frame->length > BitstreamPos(&bs) / 8))) { |
1580 |
#endif |
#endif |
1581 |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
image_output(&dec->cur, dec->width, dec->height, dec->edged_width, |
1582 |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
frame->image, frame->stride, frame->colorspace, dec->interlacing); |
1583 |
|
|
1584 |
#ifdef BFRAMES_DEC |
#ifdef BFRAMES_DEC |
1585 |
} else { |
} else { |
1586 |
if (dec->frames >= 1) { |
if (dec->frames >= 1 && !(dec->packed_mode)) { |
1587 |
start_timer(); |
start_timer(); |
1588 |
if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { |
if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { |
1589 |
image_output(&dec->refn[0], dec->width, dec->height, |
image_output(&dec->refn[0], dec->width, dec->height, |
1615 |
mb_swap(&dec->mbs, &dec->last_mbs); |
mb_swap(&dec->mbs, &dec->last_mbs); |
1616 |
} |
} |
1617 |
|
|
1618 |
|
success = 1; |
1619 |
|
|
1620 |
|
if (frame->length > BitstreamPos(&bs) / 8) // multiple vops packed together |
1621 |
|
goto start; |
1622 |
|
|
1623 |
|
done : |
1624 |
|
|
1625 |
|
frame->length = BitstreamPos(&bs) / 8; |
1626 |
|
|
1627 |
if (stats) |
if (stats) |
1628 |
{ |
{ |
1629 |
stats->notify = XVID_DEC_VOP; |
stats->notify = XVID_DEC_VOP; |