--- bitstream.c 2010/08/10 15:00:06 1.59 +++ bitstream.c 2010/12/28 19:19:43 1.61 @@ -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.59 2010/08/10 15:00:06 Isibaar Exp $ + * $Id: bitstream.c,v 1.61 2010/12/28 19:19:43 Isibaar Exp $ * ****************************************************************************/ @@ -1072,7 +1072,8 @@ void BitstreamWriteVolHeader(Bitstream * const bs, const MBParam * pParam, - const FRAMEINFO * const frame) + const FRAMEINFO * const frame, + const int num_slices) { static const unsigned int vo_id = 0; static const unsigned int vol_id = 0; @@ -1237,7 +1238,12 @@ } BitstreamPutBit(bs, 1); /* complexity_estimation_disable */ - BitstreamPutBit(bs, 1); /* resync_marker_disable */ + + if (num_slices > 1) + BitstreamPutBit(bs, 0); /* resync_marker_enabled */ + else + BitstreamPutBit(bs, 1); /* resync_marker_disabled */ + BitstreamPutBit(bs, 0); /* data_partitioned */ if (vol_ver_id != 1) { @@ -1252,7 +1258,7 @@ /* divx5 userdata string */ #define DIVX5_ID ((char *)"DivX503b1393") if ((pParam->global_flags & XVID_GLOBAL_DIVX5_USERDATA)) { - BitstreamWriteUserData(bs, DIVX5_ID, strlen(DIVX5_ID)); + BitstreamWriteUserData(bs, DIVX5_ID, (uint32_t)strlen(DIVX5_ID)); if (pParam->max_bframes > 0 && (pParam->global_flags & XVID_GLOBAL_PACKED)) BitstreamPutBits(bs, 'p', 8); } @@ -1265,7 +1271,7 @@ xvid_user_format, XVID_BS_VERSION, (frame->vop_flags & XVID_VOP_CARTOON)?'C':'\0'); - BitstreamWriteUserData(bs, xvid_user_data, strlen(xvid_user_data)); + BitstreamWriteUserData(bs, xvid_user_data, (uint32_t)strlen(xvid_user_data)); } } @@ -1386,7 +1392,7 @@ const char *data, const unsigned int length) { - int i; + unsigned int i; BitstreamPad(bs); BitstreamPutBits(bs, USERDATA_START_CODE, 32); @@ -1446,12 +1452,11 @@ if (frame->coding_type == I_VOP) nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER; /* 16 zeros followed by a 1. */ - else if (frame->coding_type == P_VOP) - nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER-1 + frame->fcode; - else /* B_VOP */ - nbitsresyncmarker = MAX(NUMBITS_VP_RESYNC_MARKER+1, NUMBITS_VP_RESYNC_MARKER-1 + MAX(frame->fcode, frame->bcode)); + else if (frame->coding_type == B_VOP) /* B_VOP */ + nbitsresyncmarker = MAX(NUMBITS_VP_RESYNC_MARKER+1, NUMBITS_VP_RESYNC_MARKER + MAX(frame->fcode, frame->bcode) - 1); + else /*(frame->coding_type == P_VOP)*/ + nbitsresyncmarker = NUMBITS_VP_RESYNC_MARKER + frame->fcode - 1; - BitstreamPadAlways(bs); BitstreamPutBits(bs, RESYNC_MARKER, nbitsresyncmarker); BitstreamPutBits(bs, mbnum, mbnum_bits); BitstreamPutBits(bs, frame->quant, 5);