--- bitstream.c 2003/01/11 14:59:24 1.28.2.16 +++ bitstream.c 2003/02/08 03:53:08 1.28.2.20 @@ -41,8 +41,8 @@ * * * Revision history: * * * - * 05.01.2003 GMC support - gruel * - * 04.10.2002 qpel support - Isibaar * + * 05.01.2003 GMC support - gruel * + * 04.10.2002 qpel support - Isibaar * * 11.07.2002 add VOP width & height return to dec when dec->width * * or dec->height is 0 (for use in examples/ex1.c) * * MinChen * @@ -558,18 +558,29 @@ DPRINTF(DPRINTF_HEADER, "low_delay %i", dec->low_delay); if (BitstreamGetBit(bs)) // vbv_parameters { + unsigned int bitrate; + unsigned int buffer_size; + unsigned int occupancy; + DPRINTF(DPRINTF_HEADER,"+ vbv_parameters"); - BitstreamSkip(bs, 15); // first_half_bitrate + + bitrate = BitstreamGetBits(bs,15) << 15; // first_half_bit_rate READ_MARKER(); - BitstreamSkip(bs, 15); // latter_half_bitrate + bitrate |= BitstreamGetBits(bs,15); // latter_half_bit_rate READ_MARKER(); - BitstreamSkip(bs, 15); // first_half_vbv_buffer_size + + buffer_size = BitstreamGetBits(bs, 15) << 3; // first_half_vbv_buffer_size READ_MARKER(); - BitstreamSkip(bs, 3); // latter_half_vbv_buffer_size - BitstreamSkip(bs, 11); // first_half_vbv_occupancy + buffer_size |= BitstreamGetBits(bs, 3); // latter_half_vbv_buffer_size + + occupancy = BitstreamGetBits(bs, 11) << 15; // first_half_vbv_occupancy READ_MARKER(); - BitstreamSkip(bs, 15); // latter_half_vbv_occupancy + occupancy |= BitstreamGetBits(bs, 15); // latter_half_vbv_occupancy READ_MARKER(); + + DPRINTF(DPRINTF_HEADER,"bitrate %d (unit=400 bps)", bitrate); + DPRINTF(DPRINTF_HEADER,"buffer_size %d (unit=16384 bits)", buffer_size); + DPRINTF(DPRINTF_HEADER,"occupancy %d (unit=64 bits)", occupancy); } }else{ dec->low_delay = dec->low_delay_default; @@ -1131,7 +1142,10 @@ profile = 0xf3; /* advanced simple profile/level 2 */ // visual_object_sequence_start_code - BitstreamPad(bs); +// BitstreamPad(bs); +/* no padding here, anymore. You have to make sure that you are + byte aligned, and that always 1-8 padding bits have been written */ + BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32); BitstreamPutBits(bs, profile, 8); @@ -1146,6 +1160,7 @@ BitstreamPutBits(bs, VIDOBJ_START_CODE|(vo_id&0x5), 32); // video_object_layer_start_code & vol_id + BitstreamPad(bs); BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32); BitstreamPutBit(bs, 0); // random_accessible_vol @@ -1279,7 +1294,10 @@ { uint32_t i; - BitstreamPad(bs); +// BitstreamPad(bs); +/* no padding here, anymore. You have to make sure that you are + byte aligned, and that always 1-8 padding bits have been written */ + BitstreamPutBits(bs, VOP_START_CODE, 32); BitstreamPutBits(bs, frame->coding_type, 2); @@ -1326,17 +1344,11 @@ int k; for (k=0;k<2;k++) { - if (pParam->m_quarterpel) - bs_put_spritetrajectory(bs, frame->warp.duv[k].x/2 ); // du[k] - else bs_put_spritetrajectory(bs, frame->warp.duv[k].x ); // du[k] - WRITE_MARKER(); + WRITE_MARKER(); - if (pParam->m_quarterpel) - bs_put_spritetrajectory(bs, frame->warp.duv[k].y/2 ); // dv[k] - else bs_put_spritetrajectory(bs, frame->warp.duv[k].y ); // dv[k] - WRITE_MARKER(); + WRITE_MARKER(); if (pParam->m_quarterpel) { @@ -1348,9 +1360,6 @@ } } } -/* GMC is halfpel in bitstream, even though GMC_MV was pseudo-qpel (2*halfpel) */ - - // no support for brightness_change! }