[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.8, Wed May 1 13:00:02 2002 UTC
# Line 41  Line 41 
41    *                                                                                                                                                        *    *                                                                                                                                                        *
42    *  Revision history:                                                         *    *  Revision history:                                                         *
43    *                                                                            *    *                                                                            *
44      *  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 54  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 63  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 283  Line 295 
295    
296                                  }                                  }
297    
298                                  if (BitstreamGetBit(bs))                                // interlaced                                  if ((dec->interlacing = BitstreamGetBit(bs)))
299                                  {                                  {
300                                          DEBUG("TODO: interlaced");                                          DEBUG("vol: interlacing");
                                         // TODO  
                                         return -1;  
301                                  }                                  }
302    
303                                  if (!BitstreamGetBit(bs))                               // obmc_disable                                  if (!BitstreamGetBit(bs))                               // obmc_disable
# Line 517  Line 527 
527                                  // intra_dc_vlc_threshold                                  // intra_dc_vlc_threshold
528                                  *intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ];                                  *intra_dc_threshold = intra_dc_threshold_table[ BitstreamGetBits(bs,3) ];
529    
530                                  /* if (interlaced)                                  if (dec->interlacing)
531                                          {                                          {
532                                                  BitstreamSkip(bs, 1);           // top_field_first                                          if ((dec->top_field_first = BitstreamGetBit(bs)))
533                                                  BitstreamSkip(bs, 1);           // alternative_vertical_scan_flag                                          {
534                                  */                                                  DEBUG("vop: top_field_first");
535                                            }
536                                            if ((dec->alternate_vertical_scan = BitstreamGetBit(bs)))
537                                            {
538                                                    DEBUG("vop: alternate_vertical_scan");
539                                            }
540                                    }
541                          }                          }
542    
543                          *quant = BitstreamGetBits(bs, dec->quant_bits);         // vop_quant                          *quant = BitstreamGetBits(bs, dec->quant_bits);         // vop_quant
# Line 584  Line 600 
600          write vol header          write vol header
601  */  */
602  void BitstreamWriteVolHeader(Bitstream * const bs,  void BitstreamWriteVolHeader(Bitstream * const bs,
603                                                  const int width,                                                  const MBParam * pParam,  const FRAMEINFO * frame)
                                                 const int height,  
                                                 const int quant_type)  
604  {  {
605          // video object_start_code & vo_id          // video object_start_code & vo_id
606      BitstreamPad(bs);      BitstreamPad(bs);
# Line 622  Line 636 
636          // BitstreamPutBits(bs, 0, 15);          // BitstreamPutBits(bs, 0, 15);
637    
638          WRITE_MARKER();          WRITE_MARKER();
639          BitstreamPutBits(bs, width, 13);                // width          BitstreamPutBits(bs, pParam->width, 13);                // width
640          WRITE_MARKER();          WRITE_MARKER();
641          BitstreamPutBits(bs, height, 13);               // height          BitstreamPutBits(bs, pParam->height, 13);               // height
642          WRITE_MARKER();          WRITE_MARKER();
643    
644          BitstreamPutBit(bs, 0);         // 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, quant_type);          BitstreamPutBit(bs, pParam->m_quant_type);
651    
652          if (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 667  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                            VOP_TYPE prediction_type,                                                  const MBParam * pParam,
685                            const int rounding_type,                                                  const FRAMEINFO * frame)
                           const uint32_t quant,  
                           const uint32_t fcode)  
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, prediction_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 (prediction_type != I_VOP)          if (frame->coding_type != I_VOP)
721                  BitstreamPutBits(bs, 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          BitstreamPutBits(bs, quant, 5);                 // quantizer          if (frame->global_flags & XVID_INTERLACING)
726            {
727                    BitstreamPutBit(bs, 1);         // top field first
728                    BitstreamPutBit(bs, 0);         // alternate vertical scan
729            }
730    
731            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 (prediction_type != I_VOP)  
                 BitstreamPutBits(bs, fcode, 3);         // fixed_code = [1,4]  
739  }  }

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

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