41 |
* * |
* * |
42 |
* Revision history: * |
* Revision history: * |
43 |
* * |
* * |
44 |
|
* 26.03.2002 interlacing support |
45 |
* 03.03.2002 qmatrix writing * |
* 03.03.2002 qmatrix writing * |
46 |
* 03.03.2002 merged BITREADER and BITWRITER * |
* 03.03.2002 merged BITREADER and BITWRITER * |
47 |
* 30.02.2002 intra_dc_threshold support * |
* 30.02.2002 intra_dc_threshold support * |
284 |
|
|
285 |
} |
} |
286 |
|
|
287 |
if (BitstreamGetBit(bs)) // interlaced |
if (dec->interlacing = BitstreamGetBit(bs)) |
288 |
{ |
{ |
289 |
DEBUG("TODO: interlaced"); |
DEBUG("vol: interlacing"); |
|
// TODO |
|
|
return -1; |
|
290 |
} |
} |
291 |
|
|
292 |
if (!BitstreamGetBit(bs)) // obmc_disable |
if (!BitstreamGetBit(bs)) // obmc_disable |
516 |
// intra_dc_vlc_threshold |
// intra_dc_vlc_threshold |
517 |
*intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ]; |
*intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ]; |
518 |
|
|
519 |
/* if (interlaced) |
if (dec->interlacing) |
520 |
{ |
{ |
521 |
BitstreamSkip(bs, 1); // top_field_first |
if (dec->top_field_first = BitstreamGetBit(bs)) |
522 |
BitstreamSkip(bs, 1); // alternative_vertical_scan_flag |
{ |
523 |
*/ |
DEBUG("vop: top_field_first"); |
524 |
|
} |
525 |
|
if (dec->alternate_vertical_scan = BitstreamGetBit(bs)) |
526 |
|
{ |
527 |
|
DEBUG("vop: alternate_vertical_scan"); |
528 |
|
} |
529 |
|
} |
530 |
} |
} |
531 |
|
|
532 |
*quant = BitstreamGetBits(bs, dec->quant_bits); // vop_quant |
*quant = BitstreamGetBits(bs, dec->quant_bits); // vop_quant |
589 |
write vol header |
write vol header |
590 |
*/ |
*/ |
591 |
void BitstreamWriteVolHeader(Bitstream * const bs, |
void BitstreamWriteVolHeader(Bitstream * const bs, |
592 |
const int width, |
const MBParam * pParam) |
|
const int height, |
|
|
const int quant_type) |
|
593 |
{ |
{ |
594 |
// video object_start_code & vo_id |
// video object_start_code & vo_id |
595 |
BitstreamPad(bs); |
BitstreamPad(bs); |
625 |
// BitstreamPutBits(bs, 0, 15); |
// BitstreamPutBits(bs, 0, 15); |
626 |
|
|
627 |
WRITE_MARKER(); |
WRITE_MARKER(); |
628 |
BitstreamPutBits(bs, width, 13); // width |
BitstreamPutBits(bs, pParam->width, 13); // width |
629 |
WRITE_MARKER(); |
WRITE_MARKER(); |
630 |
BitstreamPutBits(bs, height, 13); // height |
BitstreamPutBits(bs, pParam->height, 13); // height |
631 |
WRITE_MARKER(); |
WRITE_MARKER(); |
632 |
|
|
633 |
BitstreamPutBit(bs, 0); // interlace |
BitstreamPutBit(bs, pParam->global_flags & XVID_INTERLACING); // interlace |
634 |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
BitstreamPutBit(bs, 1); // obmc_disable (overlapped block motion compensation) |
635 |
BitstreamPutBit(bs, 0); // sprite_enable |
BitstreamPutBit(bs, 0); // sprite_enable |
636 |
BitstreamPutBit(bs, 0); // not_in_bit |
BitstreamPutBit(bs, 0); // not_in_bit |
637 |
|
|
638 |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
// quant_type 0=h.263 1=mpeg4(quantizer tables) |
639 |
BitstreamPutBit(bs, quant_type); |
BitstreamPutBit(bs, pParam->quant_type); |
640 |
|
|
641 |
if (quant_type) |
if (pParam->quant_type) |
642 |
{ |
{ |
643 |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat |
644 |
if (get_intra_matrix_status()) |
if (get_intra_matrix_status()) |
670 |
(decoder uses these values to determine precise time since last resync) |
(decoder uses these values to determine precise time since last resync) |
671 |
*/ |
*/ |
672 |
void BitstreamWriteVopHeader(Bitstream * const bs, |
void BitstreamWriteVopHeader(Bitstream * const bs, |
673 |
VOP_TYPE prediction_type, |
const MBParam * pParam) |
|
const int rounding_type, |
|
|
const uint32_t quant, |
|
|
const uint32_t fcode) |
|
674 |
{ |
{ |
675 |
BitstreamPad(bs); |
BitstreamPad(bs); |
676 |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
BitstreamPutBits(bs, VOP_START_CODE, 32); |
677 |
|
|
678 |
BitstreamPutBits(bs, prediction_type, 2); |
BitstreamPutBits(bs, pParam->coding_type, 2); |
679 |
|
|
680 |
// time_base = 0 write n x PutBit(1), PutBit(0) |
// time_base = 0 write n x PutBit(1), PutBit(0) |
681 |
BitstreamPutBits(bs, 0, 1); |
BitstreamPutBits(bs, 0, 1); |
689 |
|
|
690 |
BitstreamPutBits(bs, 1, 1); // vop_coded |
BitstreamPutBits(bs, 1, 1); // vop_coded |
691 |
|
|
692 |
if (prediction_type != I_VOP) |
if (pParam->coding_type != I_VOP) |
693 |
BitstreamPutBits(bs, rounding_type, 1); |
BitstreamPutBits(bs, pParam->rounding_type, 1); |
694 |
|
|
695 |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
BitstreamPutBits(bs, 0, 3); // intra_dc_vlc_threshold |
696 |
|
|
697 |
BitstreamPutBits(bs, quant, 5); // quantizer |
if (pParam->global_flags & XVID_INTERLACING) |
698 |
|
{ |
699 |
|
BitstreamPutBit(bs, 1); // top field first |
700 |
|
BitstreamPutBit(bs, 0); // alternate vertical scan |
701 |
|
} |
702 |
|
|
703 |
|
BitstreamPutBits(bs, pParam->quant, 5); // quantizer |
704 |
|
|
705 |
if (prediction_type != I_VOP) |
if (pParam->coding_type != I_VOP) |
706 |
BitstreamPutBits(bs, fcode, 3); // fixed_code = [1,4] |
BitstreamPutBits(bs, pParam->fixed_code, 3); // fixed_code = [1,4] |
707 |
} |
} |