--- bitstream.c 2002/05/03 08:37:55 1.10 +++ bitstream.c 2002/05/09 00:15:51 1.13 @@ -41,7 +41,11 @@ * * * Revision history: * * * - * 01.05.2002 added BVOP support to BitstreamWriteVopHeader + * 08.05.2002 add low_delay support for B_VOP decode * + * MinChen * + * 06.05.2002 low_delay * + * 06.05.2002 fixed fincr/fbase error * + * 01.05.2002 added BVOP support to BitstreamWriteVopHeader * * 15.04.2002 rewrite log2bin use asm386 By MinChen * * 26.03.2002 interlacing support * * 03.03.2002 qmatrix writing * @@ -58,7 +62,7 @@ #include "../quant/quant_matrix.h" -static int __inline log2bin(int value) +static uint32_t __inline log2bin(uint32_t value) { /* Changed by Chenm001 */ #ifndef WIN32 @@ -222,7 +226,7 @@ { DEBUG("+ vol_control_parameters"); BitstreamSkip(bs, 2); // chroma_format - BitstreamSkip(bs, 1); // low_delay + dec->low_delay=BitstreamGetBit(bs); // low_delay if (BitstreamGetBit(bs)) // vbv_parameters { DEBUG("+ vbv_parameters"); @@ -641,7 +645,23 @@ BitstreamPutBits(bs, 0, 8); // video_object_type_indication BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) - BitstreamPutBit(bs, 0); // vol_control_parameters (0=not given) + +#ifdef BFRAMES + if (pParam->max_bframes > 0) + { + dprintf("low_delay=1"); + BitstreamPutBit(bs, 1); // vol_control_parameters + BitstreamPutBits(bs, 1, 2); // chroma_format 1="4:2:0" + BitstreamPutBit(bs, 0); // low_delay + BitstreamPutBit(bs, 0); // vbv_parameters (0=not given) + } + else +#endif + { + BitstreamPutBits(bs, 0, 1); // vol_control_parameters (0=not given) + } + + BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) WRITE_MARKER(); @@ -651,7 +671,11 @@ 25fps res=25 inc=1 29.97fps res=30000 inc=1001 */ +#ifdef BFRAMES + BitstreamPutBits(bs, pParam->fbase, 16); +#else BitstreamPutBits(bs, 2, 16); +#endif WRITE_MARKER(); @@ -733,7 +757,7 @@ // time_increment: value=nth_of_sec, nbits = log2(resolution) #ifdef BFRAMES - BitstreamPutBits(bs, frame->ticks, 5); + BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase)); dprintf("[%i:%i] %c\n", frame->seconds, frame->ticks, frame->coding_type == I_VOP ? 'I' : frame->coding_type == P_VOP ? 'P' : 'B'); #else BitstreamPutBits(bs, 1, 1); @@ -743,7 +767,7 @@ BitstreamPutBits(bs, 1, 1); // vop_coded - if (frame->coding_type != I_VOP) + if (frame->coding_type == P_VOP) BitstreamPutBits(bs, frame->rounding_type, 1); BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold