[cvs] / xvidcore / src / bitstream / bitstream.c Repository:
ViewVC logotype

Diff of /xvidcore/src/bitstream/bitstream.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4, Tue Mar 26 11:16:08 2002 UTC revision 1.8, Wed May 1 13:00:02 2002 UTC
# Line 41  Line 41 
41    *                                                                                                                                                        *    *                                                                                                                                                        *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44    *  26.03.2002 interlacing support    *  01.05.2002 added BVOP support to BitstreamWriteVopHeader
45      *  15.04.2002 rewrite log2bin use asm386  By MinChen <chenm001@163.com>      *
46      *  26.03.2002 interlacing support                                                                                        *
47    *  03.03.2002 qmatrix writing                                                                                            *    *  03.03.2002 qmatrix writing                                                                                            *
48    *  03.03.2002 merged BITREADER and BITWRITER                                                             *    *  03.03.2002 merged BITREADER and BITWRITER                                                             *
49    *      30.02.2002     intra_dc_threshold support                                                                         *    *      30.02.2002     intra_dc_threshold support                                                                         *
# Line 55  Line 57 
57  #include "zigzag.h"  #include "zigzag.h"
58  #include "../quant/quant_matrix.h"  #include "../quant/quant_matrix.h"
59    
60    
61  static int __inline log2bin(int value)  static int __inline log2bin(int value)
62  {  {
63    /* Changed by Chenm001 */
64    #ifndef WIN32
65          int n = 0;          int n = 0;
66          while (value)          while (value)
67          {          {
# Line 64  Line 69 
69                  n++;                  n++;
70          }          }
71          return n;          return n;
72    #else
73            __asm{
74                    bsr eax,value
75                    inc eax
76            }
77    #endif
78  }  }
79    
80    
# Line 284  Line 295 
295    
296                                  }                                  }
297    
298                                  if (dec->interlacing = BitstreamGetBit(bs))                                  if ((dec->interlacing = BitstreamGetBit(bs)))
299                                  {                                  {
300                                          DEBUG("vol: interlacing");                                          DEBUG("vol: interlacing");
301                                  }                                  }
# Line 518  Line 529 
529    
530                                  if (dec->interlacing)                                  if (dec->interlacing)
531                                  {                                  {
532                                          if (dec->top_field_first = BitstreamGetBit(bs))                                          if ((dec->top_field_first = BitstreamGetBit(bs)))
533                                          {                                          {
534                                                  DEBUG("vop: top_field_first");                                                  DEBUG("vop: top_field_first");
535                                          }                                          }
536                                          if (dec->alternate_vertical_scan = BitstreamGetBit(bs))                                          if ((dec->alternate_vertical_scan = BitstreamGetBit(bs)))
537                                          {                                          {
538                                                  DEBUG("vop: alternate_vertical_scan");                                                  DEBUG("vop: alternate_vertical_scan");
539                                          }                                          }
# Line 589  Line 600 
600          write vol header          write vol header
601  */  */
602  void BitstreamWriteVolHeader(Bitstream * const bs,  void BitstreamWriteVolHeader(Bitstream * const bs,
603                                                  const MBParam * pParam)                                                  const MBParam * pParam,  const FRAMEINFO * frame)
604  {  {
605          // video object_start_code & vo_id          // video object_start_code & vo_id
606      BitstreamPad(bs);      BitstreamPad(bs);
# Line 630  Line 641 
641          BitstreamPutBits(bs, pParam->height, 13);               // height          BitstreamPutBits(bs, pParam->height, 13);               // height
642          WRITE_MARKER();          WRITE_MARKER();
643    
644          BitstreamPutBit(bs, pParam->global_flags & XVID_INTERLACING);           // interlace          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);            // interlace
645          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)
646          BitstreamPutBit(bs, 0);         // sprite_enable          BitstreamPutBit(bs, 0);         // sprite_enable
647          BitstreamPutBit(bs, 0);         // not_in_bit          BitstreamPutBit(bs, 0);         // not_in_bit
648    
649          // quant_type   0=h.263  1=mpeg4(quantizer tables)          // quant_type   0=h.263  1=mpeg4(quantizer tables)
650          BitstreamPutBit(bs, pParam->quant_type);          BitstreamPutBit(bs, pParam->m_quant_type);
651    
652          if (pParam->quant_type)          if (pParam->m_quant_type)
653          {          {
654                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat
655                  if (get_intra_matrix_status())                  if (get_intra_matrix_status())
# Line 670  Line 681 
681    (decoder uses these values to determine precise time since last resync)    (decoder uses these values to determine precise time since last resync)
682  */  */
683  void BitstreamWriteVopHeader(Bitstream * const bs,  void BitstreamWriteVopHeader(Bitstream * const bs,
684                                                  const MBParam * pParam)                                                  const MBParam * pParam,
685                                                    const FRAMEINFO * frame)
686  {  {
687    #ifdef BFRAMES
688            uint32_t i;
689    #endif
690      BitstreamPad(bs);      BitstreamPad(bs);
691      BitstreamPutBits(bs, VOP_START_CODE, 32);      BitstreamPutBits(bs, VOP_START_CODE, 32);
692    
693      BitstreamPutBits(bs, pParam->coding_type, 2);      BitstreamPutBits(bs, frame->coding_type, 2);
694    
695          // time_base = 0  write n x PutBit(1), PutBit(0)          // time_base = 0  write n x PutBit(1), PutBit(0)
696    #ifdef BFRAMES
697            for (i = 0; i < frame->seconds; i++)
698            {
699                    BitstreamPutBit(bs, 1);
700            }
701            BitstreamPutBit(bs, 0);
702    #else
703          BitstreamPutBits(bs, 0, 1);          BitstreamPutBits(bs, 0, 1);
704    #endif
705    
706          WRITE_MARKER();          WRITE_MARKER();
707    
708          // time_increment: value=nth_of_sec, nbits = log2(resolution)          // time_increment: value=nth_of_sec, nbits = log2(resolution)
709    #ifdef BFRAMES
710            BitstreamPutBits(bs, frame->ticks, 5);
711            dprintf("[%i:%i] %c\n", frame->seconds, frame->ticks, frame->coding_type == I_VOP ? 'I' : frame->coding_type == P_VOP ? 'P' : 'B');
712    #else
713          BitstreamPutBits(bs, 1, 1);          BitstreamPutBits(bs, 1, 1);
714    #endif
715    
716          WRITE_MARKER();          WRITE_MARKER();
717    
718          BitstreamPutBits(bs, 1, 1);                             // vop_coded          BitstreamPutBits(bs, 1, 1);                             // vop_coded
719    
720          if (pParam->coding_type != I_VOP)          if (frame->coding_type != I_VOP)
721                  BitstreamPutBits(bs, pParam->rounding_type, 1);                  BitstreamPutBits(bs, frame->rounding_type, 1);
722    
723          BitstreamPutBits(bs, 0, 3);                             // intra_dc_vlc_threshold          BitstreamPutBits(bs, 0, 3);                             // intra_dc_vlc_threshold
724    
725          if (pParam->global_flags & XVID_INTERLACING)          if (frame->global_flags & XVID_INTERLACING)
726          {          {
727                  BitstreamPutBit(bs, 1);         // top field first                  BitstreamPutBit(bs, 1);         // top field first
728                  BitstreamPutBit(bs, 0);         // alternate vertical scan                  BitstreamPutBit(bs, 0);         // alternate vertical scan
729          }          }
730    
731          BitstreamPutBits(bs, pParam->quant, 5);                 // quantizer          BitstreamPutBits(bs, frame->quant, 5);                  // quantizer
732    
733            if (frame->coding_type != I_VOP)
734                    BitstreamPutBits(bs, frame->fcode, 3);          // forward_fixed_code
735    
736            if (frame->coding_type == B_VOP)
737                    BitstreamPutBits(bs, frame->bcode, 3);          // backward_fixed_code
738    
         if (pParam->coding_type != I_VOP)  
                 BitstreamPutBits(bs, pParam->fixed_code, 3);            // fixed_code = [1,4]  
739  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.8

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4