--- decoder.c 2002/11/07 10:28:15 1.37.2.8 +++ decoder.c 2002/11/19 13:21:24 1.37.2.12 @@ -55,7 +55,7 @@ * 22.12.2001 lock based interpolation * 01.12.2001 inital version; (c)2001 peter ross * - * $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 $ * *************************************************************************/ @@ -1463,6 +1463,7 @@ uint32_t intra_dc_threshold; VECTOR gmc_mv[5]; uint32_t vop_type; + int success = 0; start_global_timer(); @@ -1470,19 +1471,19 @@ BitstreamInit(&bs, frame->bitstream, frame->length); -#ifdef BFRAMES_DEC // XXX: 0x7f is only valid whilst decoding vfw xvid/divx5 avi's - if(BitstreamShowBits(&bs, 8) == 0x7f) + if(frame->length == 1 && BitstreamShowBits(&bs, 8) == 0x7f) { if (stats) stats->notify = XVID_DEC_VOP; frame->length = 1; - image_output(&dec->cur, dec->width, dec->height, dec->edged_width, + image_output(&dec->refn[0], dec->width, dec->height, dec->edged_width, frame->image, frame->stride, frame->colorspace, dec->interlacing); + emms(); return XVID_ERR_OK; } -#endif +start: // add by chenm001 // for support B-frame to reference last 2 frame dec->frames++; @@ -1494,6 +1495,9 @@ DPRINTF(DPRINTF_HEADER, "vop_type=%i", vop_type); + if (vop_type == -1 && success) + goto done; + if (vop_type == -2 || vop_type == -3) { if (vop_type == -3) @@ -1563,27 +1567,23 @@ default: if (stats) stats->notify = 0; + + emms(); return XVID_ERR_FAIL; } -#ifdef BFRAMES_DEC_DEBUG - if (frame->length != BitstreamPos(&bs) / 8){ - DEBUG2("InLen/UseLen",frame->length, BitstreamPos(&bs) / 8); - } -#endif - frame->length = BitstreamPos(&bs) / 8; - + BitstreamByteAlign(&bs); #ifdef BFRAMES_DEC // test if no B_VOP - if (dec->low_delay || dec->frames == 0) { + if (dec->low_delay || dec->frames == 0 || ((dec->packed_mode) && !(frame->length > BitstreamPos(&bs) / 8))) { #endif image_output(&dec->cur, dec->width, dec->height, dec->edged_width, frame->image, frame->stride, frame->colorspace, dec->interlacing); #ifdef BFRAMES_DEC } else { - if (dec->frames >= 1) { + if (dec->frames >= 1 && !(dec->packed_mode)) { start_timer(); if ((vop_type == I_VOP || vop_type == P_VOP || vop_type == S_VOP)) { image_output(&dec->refn[0], dec->width, dec->height, @@ -1615,6 +1615,15 @@ mb_swap(&dec->mbs, &dec->last_mbs); } + success = 1; + + if (frame->length > BitstreamPos(&bs) / 8) // multiple vops packed together + goto start; + +done : + + frame->length = BitstreamPos(&bs) / 8; + if (stats) { stats->notify = XVID_DEC_VOP;