--- bitstream.c 2002/12/14 09:39:42 1.28.2.11 +++ bitstream.c 2003/01/03 16:25:14 1.28.2.15 @@ -173,7 +173,7 @@ if (dec->shape != VIDOBJLAY_SHAPE_BINARY_ONLY) { - *quant = BitstreamGetBits(bs, 5); /* quant_scale */ + *quant = BitstreamGetBits(bs, dec->quant_bits); /* quant_scale */ DPRINTF(DPRINTF_HEADER, "quant %i", *quant); } @@ -326,7 +326,7 @@ { ESTIMATION * e = &dec->estimation; - if (e->method == 0) + if (e->method == 0 || e->method == 1) { if (coding_type == I_VOP) { if (e->opaque) BitstreamSkip(bs, 8); /* dcecs_opaque */ @@ -464,17 +464,18 @@ DPRINTF(DPRINTF_STARTCODE, ""); } else if (start_code == VISOBJ_START_CODE) { + int visobj_ver_id; DPRINTF(DPRINTF_STARTCODE, ""); BitstreamSkip(bs, 32); // visual_object_start_code if (BitstreamGetBit(bs)) // is_visual_object_identified { - vol_ver_id = BitstreamGetBits(bs, 4); // visual_object_ver_id - DPRINTF(DPRINTF_HEADER,"ver_id %i", vol_ver_id); + visobj_ver_id = BitstreamGetBits(bs, 4); // visual_object_ver_id + DPRINTF(DPRINTF_HEADER,"visobj_ver_id %i", visobj_ver_id); BitstreamSkip(bs, 3); // visual_object_priority } else { - vol_ver_id = 1; + visobj_ver_id = 1; } if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO) // visual_object_type @@ -1114,20 +1115,38 @@ const MBParam * pParam, const FRAMEINFO * const frame) { + static const unsigned int vo_id = 0; + static const unsigned int vol_id = 0; int vol_ver_id=1; + int profile = 0x03; /* simple profile/level 3 */ if ( pParam->m_quarterpel || (frame->global_flags & XVID_GMC) || (pParam->global & XVID_GLOBAL_REDUCED)) vol_ver_id = 2; + + if ((pParam->global & XVID_GLOBAL_REDUCED)) + profile = 0x93; /* advanced realtime simple profile/level 3 */ + + if (pParam->m_quarterpel || (frame->global_flags & XVID_GMC)) + profile = 0xf3; /* advanced simple profile/level 2 */ + + // visual_object_sequence_start_code + BitstreamPad(bs); + BitstreamPutBits(bs, VISOBJSEQ_START_CODE, 32); + BitstreamPutBits(bs, profile, 8); + + // visual_object_start_code + BitstreamPad(bs); + BitstreamPutBits(bs, VISOBJ_START_CODE, 32); + BitstreamPutBits(bs, 0, 1); // is_visual_object_identifier + BitstreamPutBits(bs, VISOBJ_TYPE_VIDEO, 4); // visual_object_type // video object_start_code & vo_id BitstreamPad(bs); - BitstreamPutBits(bs, VO_START_CODE, 27); - BitstreamPutBits(bs, 0, 5); + BitstreamPutBits(bs, VIDOBJ_START_CODE|(vo_id&0x5), 32); // video_object_layer_start_code & vol_id - BitstreamPutBits(bs, VOL_START_CODE, 28); - BitstreamPutBits(bs, 0, 4); + BitstreamPutBits(bs, VIDOBJLAY_START_CODE|(vol_id&0x4), 32); BitstreamPutBit(bs, 0); // random_accessible_vol BitstreamPutBits(bs, 0, 8); // video_object_type_indication @@ -1236,6 +1255,15 @@ BitstreamPutBit(bs, 0); // scalability + /* fake divx5 id, to ensure compatibility with divx5 decoder */ +#define DIVX5_ID "DivX501b481p" + if (pParam->max_bframes > 0 && (pParam->global & XVID_GLOBAL_PACKED)) { + BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); + } + + /* xvid id */ +#define XVID_ID "XviD" XVID_BS_VERSION + BitstreamWriteUserData(bs, XVID_ID, strlen(XVID_ID)); }