--- trunk/xvidcore/src/bitstream/bitstream.c 2005/05/23 09:29:43 1617 +++ trunk/xvidcore/src/bitstream/bitstream.c 2010/08/10 15:00:34 1891 @@ -20,7 +20,7 @@ * along with this program ; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: bitstream.c,v 1.52 2005-05-23 09:29:43 Skal Exp $ + * $Id: bitstream.c,v 1.59 2010-08-10 15:00:06 Isibaar Exp $ * ****************************************************************************/ @@ -65,7 +65,7 @@ }; -void +static void bs_get_matrix(Bitstream * bs, uint8_t * matrix) { @@ -423,18 +423,17 @@ DPRINTF(XVID_DEBUG_STARTCODE, "\n"); } else if (start_code == VISOBJ_START_CODE) { - int visobj_ver_id; DPRINTF(XVID_DEBUG_STARTCODE, "\n"); BitstreamSkip(bs, 32); /* visual_object_start_code */ if (BitstreamGetBit(bs)) /* is_visual_object_identified */ { - visobj_ver_id = BitstreamGetBits(bs, 4); /* visual_object_ver_id */ - DPRINTF(XVID_DEBUG_HEADER,"visobj_ver_id %i\n", visobj_ver_id); + dec->ver_id = BitstreamGetBits(bs, 4); /* visual_object_ver_id */ + DPRINTF(XVID_DEBUG_HEADER,"visobj_ver_id %i\n", dec->ver_id); BitstreamSkip(bs, 3); /* visual_object_priority */ } else { - visobj_ver_id = 1; + dec->ver_id = 1; } if (BitstreamShowBits(bs, 4) != VISOBJ_TYPE_VIDEO) /* visual_object_type */ @@ -483,7 +482,7 @@ DPRINTF(XVID_DEBUG_HEADER,"ver_id %i\n", vol_ver_id); BitstreamSkip(bs, 3); /* video_object_layer_priority */ } else { - vol_ver_id = 1; + vol_ver_id = dec->ver_id; } dec->aspect_ratio = BitstreamGetBits(bs, 4); @@ -816,11 +815,12 @@ dec->time_base += time_incr; dec->time = dec->time_base*dec->time_inc_resolution + time_increment; dec->time_pp = (int32_t)(dec->time - dec->last_non_b_time); - dec->last_non_b_time = dec->time; + dec->last_non_b_time = dec->time; } else { - dec->time = (dec->last_time_base + time_incr)*dec->time_inc_resolution + time_increment; + dec->time = (dec->last_time_base + time_incr)*dec->time_inc_resolution + time_increment; dec->time_bp = dec->time_pp - (int32_t)(dec->last_non_b_time - dec->time); } + if (dec->time_pp <= 0) dec->time_pp = 1; DPRINTF(XVID_DEBUG_HEADER,"time_pp=%i\n", dec->time_pp); DPRINTF(XVID_DEBUG_HEADER,"time_bp=%i\n", dec->time_bp); @@ -1024,6 +1024,11 @@ version, build, dec->packed_mode); } + if ((dec->bs_version == 0) && (build > 0) && + (build != 1393)) { /* non-xvid stream with xvid fourcc */ + dec->bs_version = 0xffff; + } + } else /* start_code == ? */ { if (BitstreamShowBits(bs, 24) == 0x000001) { @@ -1076,14 +1081,9 @@ int vol_profile = pParam->profile; if ( (pParam->vol_flags & XVID_VOL_QUARTERPEL) || - (pParam->vol_flags & XVID_VOL_GMC) || - (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)) + (pParam->vol_flags & XVID_VOL_GMC)) vol_ver_id = 2; - if ((pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)) { - vol_type_ind = VIDOBJLAY_TYPE_ART_SIMPLE; - } - if ((pParam->vol_flags & (XVID_VOL_MPEGQUANT|XVID_VOL_QUARTERPEL|XVID_VOL_GMC|XVID_VOL_INTERLACING)) || pParam->max_bframes>0) { vol_type_ind = VIDOBJLAY_TYPE_ASP; @@ -1180,12 +1180,12 @@ WRITE_MARKER(); - if (pParam->fincr>0) { - BitstreamPutBit(bs, 1); /* fixed_vop_rate = 1 */ - BitstreamPutBits(bs, pParam->fincr, MAX(log2bin(pParam->fbase-1),1)); /* fixed_vop_time_increment */ - }else{ - BitstreamPutBit(bs, 0); /* fixed_vop_rate = 0 */ - } + if (pParam->fincr>0) { + BitstreamPutBit(bs, 1); /* fixed_vop_rate = 1 */ + BitstreamPutBits(bs, pParam->fincr, MAX(log2bin(pParam->fbase-1),1)); /* fixed_vop_time_increment */ + }else{ + BitstreamPutBit(bs, 0); /* fixed_vop_rate = 0 */ + } WRITE_MARKER(); BitstreamPutBits(bs, pParam->width, 13); /* width */ @@ -1242,8 +1242,7 @@ if (vol_ver_id != 1) { BitstreamPutBit(bs, 0); /* newpred_enable */ - BitstreamPutBit(bs, (pParam->vol_flags & XVID_VOL_REDUCED_ENABLE)?1:0); - /* reduced_resolution_vop_enabled */ + BitstreamPutBit(bs, 0); /* reduced_resolution_vop_enabled */ } BitstreamPutBit(bs, 0); /* scalability */ @@ -1337,9 +1336,6 @@ if ( (frame->coding_type == P_VOP) || (frame->coding_type == S_VOP) ) BitstreamPutBits(bs, frame->rounding_type, 1); - if ((frame->vol_flags & XVID_VOL_REDUCED_ENABLE)) - BitstreamPutBit(bs, 0); - BitstreamPutBits(bs, 0, 3); /* intra_dc_vlc_threshold */ if ((frame->vol_flags & XVID_VOL_INTERLACING)) { @@ -1453,7 +1449,7 @@ else if (frame->coding_type == P_VOP) nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER-1 + frame->fcode; else /* B_VOP */ - nbitsresyncmarker = MAX(NUMBITS_VP_RESYNC_MARKER, NUMBITS_VP_RESYNC_MARKER-1 + MAX(frame->fcode, frame->bcode)); + nbitsresyncmarker = MAX(NUMBITS_VP_RESYNC_MARKER+1, NUMBITS_VP_RESYNC_MARKER-1 + MAX(frame->fcode, frame->bcode)); BitstreamPadAlways(bs); BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker);