[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.3, Sat Mar 9 21:40:36 2002 UTC revision 1.7, Thu Apr 25 06:55:00 2002 UTC
# Line 41  Line 41 
41    *                                                                                                                                                        *    *                                                                                                                                                        *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44      *  15.04.2002 rewrite log2bin use asm386  By MinChen <chenm001@163.com>      *
45      *  26.03.2002 interlacing support                                                                                        *
46    *  03.03.2002 qmatrix writing                                                                                            *    *  03.03.2002 qmatrix writing                                                                                            *
47    *  03.03.2002 merged BITREADER and BITWRITER                                                             *    *  03.03.2002 merged BITREADER and BITWRITER                                                             *
48    *      30.02.2002     intra_dc_threshold support                                                                         *    *      30.02.2002     intra_dc_threshold support                                                                         *
# Line 54  Line 56 
56  #include "zigzag.h"  #include "zigzag.h"
57  #include "../quant/quant_matrix.h"  #include "../quant/quant_matrix.h"
58    
59    
60  static int __inline log2bin(int value)  static int __inline log2bin(int value)
61  {  {
62    /* Changed by Chenm001 */
63    #ifndef WIN32
64          int n = 0;          int n = 0;
65          while (value)          while (value)
66          {          {
# Line 63  Line 68 
68                  n++;                  n++;
69          }          }
70          return n;          return n;
71    #else
72            __asm{
73                    bsr eax,value
74                    inc eax
75            }
76    #endif
77  }  }
78    
79    
# Line 283  Line 294 
294    
295                                  }                                  }
296    
297                                  if (BitstreamGetBit(bs))                                // interlaced                                  if ((dec->interlacing = BitstreamGetBit(bs)))
298                                  {                                  {
299                                          DEBUG("TODO: interlaced");                                          DEBUG("vol: interlacing");
                                         // TODO  
                                         return -1;  
300                                  }                                  }
301    
302                                  if (!BitstreamGetBit(bs))                               // obmc_disable                                  if (!BitstreamGetBit(bs))                               // obmc_disable
# Line 517  Line 526 
526                                  // intra_dc_vlc_threshold                                  // intra_dc_vlc_threshold
527                                  *intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ];                                  *intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ];
528    
529                                  /* if (interlaced)                                  if (dec->interlacing)
530                                          {                                          {
531                                                  BitstreamSkip(bs, 1);           // top_field_first                                          if ((dec->top_field_first = BitstreamGetBit(bs)))
532                                                  BitstreamSkip(bs, 1);           // alternative_vertical_scan_flag                                          {
533                                  */                                                  DEBUG("vop: top_field_first");
534                                            }
535                                            if ((dec->alternate_vertical_scan = BitstreamGetBit(bs)))
536                                            {
537                                                    DEBUG("vop: alternate_vertical_scan");
538                                            }
539                                    }
540                          }                          }
541    
542                          *quant = BitstreamGetBits(bs, dec->quant_bits);         // vop_quant                          *quant = BitstreamGetBits(bs, dec->quant_bits);         // vop_quant
# Line 584  Line 599 
599          write vol header          write vol header
600  */  */
601  void BitstreamWriteVolHeader(Bitstream * const bs,  void BitstreamWriteVolHeader(Bitstream * const bs,
602                                                  const int width,                                                  const MBParam * pParam,  const FRAMEINFO * frame)
                                                 const int height,  
                                                 const int quant_type)  
603  {  {
604          // video object_start_code & vo_id          // video object_start_code & vo_id
605      BitstreamPad(bs);      BitstreamPad(bs);
# Line 622  Line 635 
635          // BitstreamPutBits(bs, 0, 15);          // BitstreamPutBits(bs, 0, 15);
636    
637          WRITE_MARKER();          WRITE_MARKER();
638          BitstreamPutBits(bs, width, 13);                // width          BitstreamPutBits(bs, pParam->width, 13);                // width
639          WRITE_MARKER();          WRITE_MARKER();
640          BitstreamPutBits(bs, height, 13);               // height          BitstreamPutBits(bs, pParam->height, 13);               // height
641          WRITE_MARKER();          WRITE_MARKER();
642    
643          BitstreamPutBit(bs, 0);         // interlace          BitstreamPutBit(bs, frame->global_flags & XVID_INTERLACING);            // interlace
644          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)          BitstreamPutBit(bs, 1);         // obmc_disable (overlapped block motion compensation)
645          BitstreamPutBit(bs, 0);         // sprite_enable          BitstreamPutBit(bs, 0);         // sprite_enable
646          BitstreamPutBit(bs, 0);         // not_in_bit          BitstreamPutBit(bs, 0);         // not_in_bit
647    
648          // quant_type   0=h.263  1=mpeg4(quantizer tables)          // quant_type   0=h.263  1=mpeg4(quantizer tables)
649          BitstreamPutBit(bs, quant_type);          BitstreamPutBit(bs, pParam->m_quant_type);
650    
651          if (quant_type)          if (pParam->m_quant_type)
652          {          {
653                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat                  BitstreamPutBit(bs, get_intra_matrix_status()); // load_intra_quant_mat
654                  if (get_intra_matrix_status())                  if (get_intra_matrix_status())
# Line 667  Line 680 
680    (decoder uses these values to determine precise time since last resync)    (decoder uses these values to determine precise time since last resync)
681  */  */
682  void BitstreamWriteVopHeader(Bitstream * const bs,  void BitstreamWriteVopHeader(Bitstream * const bs,
683                            VOP_TYPE prediction_type,                                                  const MBParam * pParam,
684                            const int rounding_type,                                                  const FRAMEINFO * frame)
                           const uint32_t quant,  
                           const uint32_t fcode)  
685  {  {
686      BitstreamPad(bs);      BitstreamPad(bs);
687      BitstreamPutBits(bs, VOP_START_CODE, 32);      BitstreamPutBits(bs, VOP_START_CODE, 32);
688    
689      BitstreamPutBits(bs, prediction_type, 2);      BitstreamPutBits(bs, frame->coding_type, 2);
690    
691          // time_base = 0  write n x PutBit(1), PutBit(0)          // time_base = 0  write n x PutBit(1), PutBit(0)
692          BitstreamPutBits(bs, 0, 1);          BitstreamPutBits(bs, 0, 1);
# Line 689  Line 700 
700    
701          BitstreamPutBits(bs, 1, 1);                             // vop_coded          BitstreamPutBits(bs, 1, 1);                             // vop_coded
702    
703          if (prediction_type != I_VOP)          if (frame->coding_type != I_VOP)
704                  BitstreamPutBits(bs, rounding_type, 1);                  BitstreamPutBits(bs, frame->rounding_type, 1);
705    
706          BitstreamPutBits(bs, 0, 3);                             // intra_dc_vlc_threshold          BitstreamPutBits(bs, 0, 3);                             // intra_dc_vlc_threshold
707    
708          BitstreamPutBits(bs, quant, 5);                 // quantizer          if (frame->global_flags & XVID_INTERLACING)
709            {
710                    BitstreamPutBit(bs, 1);         // top field first
711                    BitstreamPutBit(bs, 0);         // alternate vertical scan
712            }
713    
714            BitstreamPutBits(bs, frame->quant, 5);                  // quantizer
715    
716          if (prediction_type != I_VOP)          if (frame->coding_type != I_VOP)
717                  BitstreamPutBits(bs, fcode, 3);         // fixed_code = [1,4]                  BitstreamPutBits(bs, frame->fcode, 3);          // fixed_code = [1,4]
718  }  }

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

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