41 |
* * |
* * |
42 |
* Revision history: * |
* Revision history: * |
43 |
* * |
* * |
44 |
* 22.05.2002 bs_put_matrix fix |
* 11.07.2002 add VOP width & height return to dec when dec->width * |
45 |
|
* or dec->height is 0 (for use in examples/ex1.c) * |
46 |
|
* MinChen <chenm001@163.com> * |
47 |
|
* 22.05.2002 bs_put_matrix fix * |
48 |
* 20.05.2002 added BitstreamWriteUserData * |
* 20.05.2002 added BitstreamWriteUserData * |
49 |
* 19.06.2002 Fix a little bug in use custom quant matrix * |
* 19.06.2002 Fix a little bug in use custom quant matrix * |
50 |
* MinChen <chenm001@163.com> * |
* MinChen <chenm001@163.com> * |
330 |
|
|
331 |
DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution); |
DPRINTF(DPRINTF_HEADER,"vop_time_increment_resolution %i", time_increment_resolution); |
332 |
|
|
333 |
time_increment_resolution--; |
// time_increment_resolution--; |
334 |
|
|
335 |
if (time_increment_resolution > 0) { |
if (time_increment_resolution > 0) { |
336 |
dec->time_inc_bits = log2bin(time_increment_resolution); |
dec->time_inc_bits = log2bin(time_increment_resolution-1); |
337 |
} else { |
} else { |
338 |
// dec->time_inc_bits = 0; |
// dec->time_inc_bits = 0; |
339 |
// for "old" xvid compatibility, set time_inc_bits = 1 |
// for "old" xvid compatibility, set time_inc_bits = 1 |
362 |
DPRINTF(DPRINTF_HEADER, "width %i", width); |
DPRINTF(DPRINTF_HEADER, "width %i", width); |
363 |
DPRINTF(DPRINTF_HEADER, "height %i", height); |
DPRINTF(DPRINTF_HEADER, "height %i", height); |
364 |
|
|
365 |
|
// for auto set width & height |
366 |
|
if (dec->width == 0) |
367 |
|
dec->width = width; |
368 |
|
if (dec->height == 0) |
369 |
|
dec->height = height; |
370 |
|
|
371 |
if (width != dec->width || height != dec->height) { |
if (width != dec->width || height != dec->height) { |
372 |
DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream"); |
DPRINTF(DPRINTF_ERROR, "XVID_DEC_PARAM width/height does not match bitstream"); |
373 |
return -1; |
return -1; |
446 |
|
|
447 |
|
|
448 |
if (vol_ver_id != 1) { |
if (vol_ver_id != 1) { |
449 |
dec->quarterpel = BitstreamGetBit(bs); // quarter_sampe |
DEBUG("QUARTERPEL BITSTREAM"); |
450 |
if (dec->quarterpel) { |
dec->quarterpel = BitstreamGetBit(bs); // quarter_sample |
|
DPRINTF(DPRINTF_ERROR, "quarter_sample not supported"); |
|
451 |
} |
} |
452 |
} else { |
else |
453 |
dec->quarterpel = 0; |
dec->quarterpel = 0; |
454 |
} |
|
455 |
|
|
456 |
if (!BitstreamGetBit(bs)) // complexity_estimation_disable |
if (!BitstreamGetBit(bs)) // complexity_estimation_disable |
457 |
{ |
{ |
546 |
if (coding_type != B_VOP) { |
if (coding_type != B_VOP) { |
547 |
dec->last_time_base = dec->time_base; |
dec->last_time_base = dec->time_base; |
548 |
dec->time_base += time_incr; |
dec->time_base += time_incr; |
549 |
dec->time = |
dec->time = time_increment; |
550 |
dec->time_base * time_increment_resolution + |
|
551 |
|
/* dec->time_base * time_increment_resolution + |
552 |
time_increment; |
time_increment; |
553 |
dec->time_pp = (uint32_t) (dec->time - dec->last_non_b_time); |
*/ dec->time_pp = (uint32_t) |
554 |
|
(time_increment_resolution + dec->time - dec->last_non_b_time)%time_increment_resolution; |
555 |
dec->last_non_b_time = dec->time; |
dec->last_non_b_time = dec->time; |
556 |
} else { |
} else { |
557 |
dec->time = |
dec->time = time_increment; |
558 |
|
/* |
559 |
(dec->last_time_base + |
(dec->last_time_base + |
560 |
time_incr) * time_increment_resolution + time_increment; |
time_incr) * time_increment_resolution + time_increment; |
561 |
dec->time_bp = (uint32_t) (dec->last_non_b_time - dec->time); |
*/ |
562 |
|
dec->time_bp = (uint32_t) |
563 |
|
(time_increment_resolution + dec->last_non_b_time - dec->time)%time_increment_resolution; |
564 |
} |
} |
565 |
|
|
566 |
READ_MARKER(); |
READ_MARKER(); |
714 |
BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) |
BitstreamPutBit(bs, 0); // is_object_layer_identified (0=not given) |
715 |
BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) |
BitstreamPutBits(bs, 1, 4); // aspect_ratio_info (1=1:1) |
716 |
|
|
|
#ifdef BFRAMES |
|
|
if (pParam->max_bframes > 0) { |
|
|
//DPRINTF("low_delay=1"); |
|
717 |
BitstreamPutBit(bs, 1); // vol_control_parameters |
BitstreamPutBit(bs, 1); // vol_control_parameters |
718 |
BitstreamPutBits(bs, 1, 2); // chroma_format 1="4:2:0" |
BitstreamPutBits(bs, 1, 2); // chroma_format 1="4:2:0" |
719 |
|
|
720 |
|
#ifdef BFRAMES |
721 |
|
if (pParam->max_bframes > 0) { |
722 |
BitstreamPutBit(bs, 0); // low_delay |
BitstreamPutBit(bs, 0); // low_delay |
|
BitstreamPutBit(bs, 0); // vbv_parameters (0=not given) |
|
723 |
} else |
} else |
724 |
#endif |
#endif |
725 |
{ |
{ |
726 |
BitstreamPutBits(bs, 0, 1); // vol_control_parameters (0=not given) |
BitstreamPutBit(bs, 1); // low_delay |
727 |
} |
} |
728 |
|
BitstreamPutBit(bs, 0); // vbv_parameters (0=not given) |
729 |
|
|
730 |
BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) |
BitstreamPutBits(bs, 0, 2); // video_object_layer_shape (0=rectangular) |
731 |
|
|
739 |
#ifdef BFRAMES |
#ifdef BFRAMES |
740 |
BitstreamPutBits(bs, pParam->fbase, 16); |
BitstreamPutBits(bs, pParam->fbase, 16); |
741 |
#else |
#else |
742 |
BitstreamPutBits(bs, 2, 16); |
BitstreamPutBits(bs, pParam->fbase, 16); |
743 |
#endif |
#endif |
744 |
|
|
745 |
WRITE_MARKER(); |
WRITE_MARKER(); |
748 |
BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 |
BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 |
749 |
BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment |
BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment |
750 |
#else |
#else |
751 |
BitstreamPutBit(bs, 0); // fixed_vop_rate = 0 |
BitstreamPutBit(bs, 1); // fixed_vop_rate = 1 |
752 |
|
BitstreamPutBits(bs, pParam->fincr, log2bin(pParam->fbase)); // fixed_vop_time_increment |
753 |
#endif |
#endif |
754 |
|
|
755 |
WRITE_MARKER(); |
WRITE_MARKER(); |
800 |
const FRAMEINFO * frame, |
const FRAMEINFO * frame, |
801 |
int vop_coded) |
int vop_coded) |
802 |
{ |
{ |
|
#ifdef BFRAMES |
|
803 |
uint32_t i; |
uint32_t i; |
804 |
#endif |
|
805 |
BitstreamPad(bs); |
BitstreamPad(bs); |
806 |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
807 |
|
|
814 |
} |
} |
815 |
BitstreamPutBit(bs, 0); |
BitstreamPutBit(bs, 0); |
816 |
#else |
#else |
817 |
BitstreamPutBits(bs, 0, 1); |
for (i = 0; i < frame->seconds; i++) { |
818 |
|
BitstreamPutBit(bs, 1); |
819 |
|
} |
820 |
|
BitstreamPutBit(bs, 0); |
821 |
|
// BitstreamPutBits(bs, 0, 1); |
822 |
#endif |
#endif |
823 |
|
|
824 |
WRITE_MARKER(); |
WRITE_MARKER(); |
830 |
frame->coding_type == I_VOP ? 'I' : frame->coding_type == |
frame->coding_type == I_VOP ? 'I' : frame->coding_type == |
831 |
P_VOP ? 'P' : 'B');*/ |
P_VOP ? 'P' : 'B');*/ |
832 |
#else |
#else |
833 |
BitstreamPutBits(bs, 1, 1); |
BitstreamPutBits(bs, frame->ticks, log2bin(pParam->fbase)); |
834 |
|
// BitstreamPutBits(bs, 1, 1); |
835 |
#endif |
#endif |
836 |
|
|
837 |
WRITE_MARKER(); |
WRITE_MARKER(); |