--- trunk/xvidcore/src/bitstream/bitstream.c 2002/06/30 10:46:29 252 +++ trunk/xvidcore/src/bitstream/bitstream.c 2002/09/03 17:25:45 387 @@ -41,7 +41,10 @@ * * * Revision history: * * * - * 22.05.2002 bs_put_matrix fix + * 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 * + * 22.05.2002 bs_put_matrix fix * * 20.05.2002 added BitstreamWriteUserData * * 19.06.2002 Fix a little bug in use custom quant matrix * * MinChen * @@ -327,10 +330,10 @@ DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution); - time_increment_resolution--; +// time_increment_resolution--; if (time_increment_resolution > 0) { - dec->time_inc_bits = log2bin(time_increment_resolution); + dec->time_inc_bits = log2bin(time_increment_resolution-1); } else { // dec->time_inc_bits = 0; // for "old" xvid compatibility, set time_inc_bits = 1 @@ -359,6 +362,12 @@ DPRINTF(DPRINTF_HEADER, "width %i", width); DPRINTF(DPRINTF_HEADER, "height %i", height); + // for auto set width & height + if (dec->width == 0) + dec->width = width; + if (dec->height == 0) + dec->height = height; + if (width != dec->width || height != dec->height) { DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream"); return -1; @@ -437,13 +446,12 @@ if (vol_ver_id != 1) { - dec->quarterpel = BitstreamGetBit(bs); // quarter_sampe - if (dec->quarterpel) { - DPRINTF(DPRINTF_ERROR, "quarter_sample not supported"); - } - } else { - dec->quarterpel = 0; + DEBUG("QUARTERPEL BITSTREAM"); + dec->quarterpel = BitstreamGetBit(bs); // quarter_sample } + else + dec->quarterpel = 0; + if (!BitstreamGetBit(bs)) // complexity_estimation_disable { @@ -538,16 +546,21 @@ if (coding_type != B_VOP) { dec->last_time_base = dec->time_base; dec->time_base += time_incr; - dec->time = - dec->time_base * time_increment_resolution + + dec->time = time_increment; + +/* dec->time_base * time_increment_resolution + time_increment; - dec->time_pp = (uint32_t) (dec->time - dec->last_non_b_time); +*/ dec->time_pp = (uint32_t) + (time_increment_resolution + dec->time - dec->last_non_b_time)%time_increment_resolution; dec->last_non_b_time = dec->time; } else { - dec->time = + dec->time = time_increment; +/* (dec->last_time_base + - time_incr) * time_increment_resolution + time_increment; - dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time); + time_incr) * time_increment_resolution + time_increment; +*/ + dec->time_bp = (uint32_t) + (time_increment_resolution + dec->last_non_b_time - dec->time)%time_increment_resolution; } READ_MARKER(); @@ -701,19 +714,18 @@ BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) + BitstreamPutBit(bs, 1); // vol_control_parameters + BitstreamPutBits(bs, 1, 2); // chroma_format 1="4:2:0" + #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) + BitstreamPutBit(bs, 1); // low_delay } - + BitstreamPutBit(bs, 0); // vbv_parameters (0=not given) BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) @@ -727,7 +739,7 @@ #ifdef BFRAMES BitstreamPutBits(bs, pParam->fbase, 16); #else - BitstreamPutBits(bs, 2, 16); + BitstreamPutBits(bs, pParam->fbase, 16); #endif WRITE_MARKER(); @@ -736,7 +748,8 @@ BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment #else - BitstreamPutBit(bs, 0); // fixed_vop_rate = 0 + BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 + BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment #endif WRITE_MARKER(); @@ -787,9 +800,8 @@ const FRAMEINFO * frame, int vop_coded) { -#ifdef BFRAMES uint32_t i; -#endif + BitstreamPad(bs); BitstreamPutBits(bs, VOP_START_CODE, 32); @@ -802,7 +814,11 @@ } BitstreamPutBit(bs, 0); #else - BitstreamPutBits(bs, 0, 1); + for (i = 0; i < frame->seconds; i++) { + BitstreamPutBit(bs, 1); + } + BitstreamPutBit(bs, 0); +// BitstreamPutBits(bs, 0, 1); #endif WRITE_MARKER(); @@ -814,7 +830,8 @@ frame->coding_type == I_VOP ? 'I' : frame->coding_type == P_VOP ? 'P' : 'B');*/ #else - BitstreamPutBits(bs, 1, 1); + BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase)); +// BitstreamPutBits(bs, 1, 1); #endif WRITE_MARKER(); @@ -861,4 +878,4 @@ BitstreamPutBits(bs, data[i], 8); } -} \ No newline at end of file +}