⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitstream.cpp

📁 gaca源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
         if (e->no_update) bs->Skip(8);   /* */
         if (e->upsampling) bs->Skip(8);  /* */
         if (e->intra_blocks) bs->Skip(8);   /* */
         if (e->not_coded_blocks)   bs->Skip(8);   /* */
         if (e->dct_coefs) bs->Skip(8);   /* */
         if (e->dct_lines) bs->Skip(8);   /* */
         if (e->vlc_symbols) bs->Skip(8); /* */
         if (e->vlc_bits)  bs->Skip(8);   /* */
         if (e->inter_blocks) bs->Skip(8);   /* */
         if (e->inter4v_blocks) bs->Skip(8); /* */
         if (e->apm)       bs->Skip(8);   /* */
         if (e->npm)       bs->Skip(8);   /* */
         if (e->forw_back_mc_q) bs->Skip(8); /* */
         if (e->halfpel2)  bs->Skip(8);   /* */
         if (e->halfpel4)  bs->Skip(8);   /* */
         if (e->sadct)     bs->Skip(8);   /* */
         if (e->quarterpel)   bs->Skip(8);   /* */
      }
      if (coding_type == B_VOP) {
         if (e->opaque)    bs->Skip(8);   /* */
         if (e->transparent)  bs->Skip(8);   /* */
         if (e->intra_cae) bs->Skip(8);   /* */
         if (e->inter_cae) bs->Skip(8);   /* */
         if (e->no_update) bs->Skip(8);   /* */
         if (e->upsampling)   bs->Skip(8);   /* */
         if (e->intra_blocks) bs->Skip(8);   /* */
         if (e->not_coded_blocks) bs->Skip(8);  /* */
         if (e->dct_coefs) bs->Skip(8);   /* */
         if (e->dct_lines) bs->Skip(8);   /* */
         if (e->vlc_symbols)  bs->Skip(8);   /* */
         if (e->vlc_bits)  bs->Skip(8);   /* */
         if (e->inter_blocks) bs->Skip(8);   /* */
         if (e->inter4v_blocks) bs->Skip(8); /* */
         if (e->apm)       bs->Skip(8);   /* */
         if (e->npm)       bs->Skip(8);   /* */
         if (e->forw_back_mc_q) bs->Skip(8); /* */
         if (e->halfpel2)  bs->Skip(8);   /* */
         if (e->halfpel4)  bs->Skip(8);   /* */
         if (e->interpolate_mc_q) bs->Skip(8);  /* */
         if (e->sadct)     bs->Skip(8);   /* */
         if (e->quarterpel)   bs->Skip(8);   /* */
      }

      if (coding_type == S_VOP && sprite_enable == SPRITE_STATIC) {
         if (e->intra_blocks) bs->Skip(8);   /* */
         if (e->not_coded_blocks) bs->Skip(8);  /* */
         if (e->dct_coefs) bs->Skip(8);   /* */
         if (e->dct_lines) bs->Skip(8);   /* */
         if (e->vlc_symbols)  bs->Skip(8);   /* */
         if (e->vlc_bits)  bs->Skip(8);   /* */
         if (e->inter_blocks) bs->Skip(8);   /* */
         if (e->inter4v_blocks)  bs->Skip(8);   /* */
         if (e->apm)       bs->Skip(8);   /* */
         if (e->npm)       bs->Skip(8);   /* */
         if (e->forw_back_mc_q)  bs->Skip(8);   /* */
         if (e->halfpel2)  bs->Skip(8);   /* */
         if (e->halfpel4)  bs->Skip(8);   /* */
         if (e->interpolate_mc_q) bs->Skip(8);  /* */
      }
   }
}

//----------------------------
// decode headers
// returns coding_type, or -1 if error

#define VIDOBJ_START_CODE_MASK      0x0000001f
#define VIDOBJLAY_START_CODE_MASK   0x0000000f

int S_decoder::BitstreamReadHeaders(Bitstream * bs, bool &rounding, bool *reduced_resolution, dword *quant, dword *fcode_forward,
   dword *fcode_backward, dword *intra_dc_threshold, WARPPOINTS *gmc_warp){

   dword vol_ver_id;
   dword coding_type;
   dword start_code;
   dword time_incr = 0;
   int time_increment = 0;
   int resize = 0;

   while((bs->Pos() >> 3) < bs->length){
      bs->ByteAlign();
      start_code = bs->ShowBits(32);

      switch(start_code){
      case VISOBJSEQ_START_CODE:
         {
            DPRINTF(XVID_DEBUG_STARTCODE, "<visual_object_sequence>\n");

            bs->Skip(32);     //visual_object_sequence_start_code
            int profile = bs->GetBits(8);  //profile_and_level_indication

            DPRINTF(XVID_DEBUG_HEADER, "profile_and_level_indication %i\n", profile);
         }
         break;
      case VISOBJSEQ_STOP_CODE:
         {
                              //visual_object_sequence_stop_code
            bs->Skip(32);
            DPRINTF(XVID_DEBUG_STARTCODE, "</visual_object_sequence>\n");
            
         }
         break;
      case VISOBJ_START_CODE:
         {
            DPRINTF(XVID_DEBUG_STARTCODE, "<visual_object>\n");
            
            bs->Skip(32);  //visual_object_start_code

            int visobj_ver_id;
                              //is_visual_object_identified
            if(bs->GetBit()){
               visobj_ver_id = bs->GetBits(4);  /* visual_object_ver_id */
               DPRINTF(XVID_DEBUG_HEADER,"visobj_ver_id %i\n", visobj_ver_id);
               bs->Skip(3);   //visual_object_priority
            }else{
               visobj_ver_id = 1;
            }
            
            if(bs->ShowBits(4) != VISOBJ_TYPE_VIDEO){
                              //visual_object_type
               DPRINTF(XVID_DEBUG_ERROR, "visual_object_type != video\n");
               return -1;
            }
            bs->Skip(4);
                              //video_signal_type
            
            if(bs->GetBit()){
               DPRINTF(XVID_DEBUG_HEADER,"+ video_signal_type\n");
               bs->Skip(3);   /* video_format */
               bs->Skip(1);   /* video_range */
               if (bs->GetBit()) /* color_description */
               {
                  DPRINTF(XVID_DEBUG_HEADER,"+ color_description");
                  bs->Skip(8);   /* color_primaries */
                  bs->Skip(8);   /* transfer_characteristics */
                  bs->Skip(8);   /* matrix_coefficients */
               }
            }
         }
         break;
      case GRPOFVOP_START_CODE:
         {
            DPRINTF(XVID_DEBUG_STARTCODE, "<group_of_vop>\n");

            bs->Skip(32);
            {
               int hours, minutes, seconds;

               hours = bs->GetBits(5);
               minutes = bs->GetBits(6);
               READ_MARKER();
               seconds = bs->GetBits(6);
               //DPRINTF(XVID_DEBUG_HEADER, "time %ih%im%is\n", hours,minutes,seconds);
            }
            bs->Skip(1);   /* closed_gov */
            bs->Skip(1);   /* broken_link */
         }
         break;
      case VOP_START_CODE:
         {
            
            DPRINTF(XVID_DEBUG_STARTCODE, "<vop>\n");
            
            bs->Skip(32);  /* vop_start_code */
            
            coding_type = bs->GetBits(2); /* vop_coding_type */
            DPRINTF(XVID_DEBUG_HEADER, "coding_type %i\n", coding_type);
            
            /*********************** for decode B-frame time ***********************/
            while (bs->GetBit() != 0)  /* time_base */
               time_incr++;
            
            READ_MARKER();
            
            if (time_inc_bits) {
               time_increment = (bs->GetBits(time_inc_bits));  /* vop_time_increment */
            }
            
            DPRINTF(XVID_DEBUG_HEADER, "time_base %i\n", time_incr);
            DPRINTF(XVID_DEBUG_HEADER, "time_increment %i\n", time_increment);
            
            //DPRINTF(XVID_DEBUG_TIMECODE, "%c %i:%i\n", coding_type == I_VOP ? 'I' : coding_type == P_VOP ? 'P' : coding_type == B_VOP ? 'B' : 'S', time_incr, time_increment);
            if (coding_type != B_VOP) {
               last_time_base = time_base;
               time_base += time_incr;
               time = time_increment;
               
#if 0
               time_base * time_inc_resolution +
                  time_increment;
#endif
               time_pp = (dword)
                  (time_inc_resolution + time - last_non_b_time)%time_inc_resolution;
               last_non_b_time = time;
            } else {
               time = time_increment;
#if 0
               (last_time_base +
                  time_incr) * time_inc_resolution + time_increment;
#endif
               time_bp = (dword)
                  (time_inc_resolution + last_non_b_time - time)%time_inc_resolution;
            }
            DPRINTF(XVID_DEBUG_HEADER,"time_pp=%i\n", time_pp);
            DPRINTF(XVID_DEBUG_HEADER,"time_bp=%i\n", time_bp);
            
            READ_MARKER();
            
            if (!bs->GetBit())   /* vop_coded */
            {
               DPRINTF(XVID_DEBUG_HEADER, "vop_coded==false\n");
               return N_VOP;
            }
            
            if (newpred_enable) {
               int vop_id;
               int vop_id_for_prediction;
               
               vop_id = bs->GetBits(MIN(time_inc_bits + 3, 15));
               DPRINTF(XVID_DEBUG_HEADER, "vop_id %i\n", vop_id);
               if (bs->GetBit()) /* vop_id_for_prediction_indication */
               {
                  vop_id_for_prediction = bs->GetBits(MIN(time_inc_bits + 3, 15));
                  DPRINTF(XVID_DEBUG_HEADER, "vop_id_for_prediction %i\n", vop_id_for_prediction);
               }
               READ_MARKER();
            }
            
                              //fix a little bug by MinChen <chenm002@163.com>
            if((shape != VIDOBJLAY_SHAPE_BINARY_ONLY) &&
               ((coding_type == P_VOP) || (coding_type == S_VOP && sprite_enable == SPRITE_GMC))){
               rounding = !!bs->GetBit();  //rounding_type
               DPRINTF(XVID_DEBUG_HEADER, "rounding %i\n", rounding);
            }
            
            if(reduced_resolution_enable && shape == VIDOBJLAY_SHAPE_RECTANGULAR && (coding_type == P_VOP || coding_type == I_VOP)) {
               
               *reduced_resolution = !!bs->GetBit();
               DPRINTF(XVID_DEBUG_HEADER, "reduced_resolution %i\n", *reduced_resolution);
            }else{
               *reduced_resolution = false;
            }
            
            if (shape != VIDOBJLAY_SHAPE_RECTANGULAR) {
               if(!(sprite_enable == SPRITE_STATIC && coding_type == I_VOP)) {
                  
                  dword width, height;
                  dword horiz_mc_ref, vert_mc_ref;
                  
                  width = bs->GetBits(13);
                  READ_MARKER();
                  height = bs->GetBits(13);
                  READ_MARKER();
                  horiz_mc_ref = bs->GetBits(13);
                  READ_MARKER();
                  vert_mc_ref = bs->GetBits(13);
                  READ_MARKER();
                  
                  DPRINTF(XVID_DEBUG_HEADER, "width %i\n", width);
                  DPRINTF(XVID_DEBUG_HEADER, "height %i\n", height);
                  DPRINTF(XVID_DEBUG_HEADER, "horiz_mc_ref %i\n", horiz_mc_ref);
                  DPRINTF(XVID_DEBUG_HEADER, "vert_mc_ref %i\n", vert_mc_ref);
               }
               
               bs->Skip(1);   /* change_conv_ratio_disable */
               if (bs->GetBit()) /* vop_constant_alpha */
               {
                  bs->Skip(8);   /* vop_constant_alpha_value */
               }
            }
            
            if (shape != VIDOBJLAY_SHAPE_BINARY_ONLY) {
               
               if (!complexity_estimation_disable)
               {
                  read_vop_complexity_estimation_header(bs, coding_type);
               }
               
               /* intra_dc_vlc_threshold */
               *intra_dc_threshold =
                  intra_dc_threshold_table[bs->GetBits(3)];
               
               top_field_first = 0;
               alternate_vertical_scan = 0;
               
               if(interlacing){
                  top_field_first = bs->GetBit();
                  DPRINTF(XVID_DEBUG_HEADER, "interlace top_field_first %i\n", top_field_first);
                  alternate_vertical_scan = bs->GetBit();
                  DPRINTF(XVID_DEBUG_HEADER, "interlace alternate_vertical_scan %i\n", alternate_vertical_scan);
                  
               }
            }
            
            if ((sprite_enable == SPRITE_STATIC || sprite_enable== SPRITE_GMC) && coding_type == S_VOP) {
               
               int i;
               
               for (i = 0 ; i < sprite_warping_points; i++)
               {
                  int length;
                  int x = 0, y = 0;
                  
                  /* sprite code borowed from ffmpeg; thx Michael Niedermayer <michaelni@gmx.at> */
                  length = bs->bs_get_spritetrajectory();
                  if(length){
                     x= bs->GetBits(length);
                     if ((x >> (length - 1)) == 0) /* if MSB not set it is negative*/
                        x = - (x ^ ((1 << length) - 1));
                  }
                  READ_MARKER();
                  
                  length = bs->bs_get_spritetrajectory();
                  if(length){
                     y = bs->GetBits(length);
                     if ((y >> (length - 1)) == 0) /* if MSB not set it is negative*/
                        y = - (y ^ ((1 << length) - 1));
                  }
                  READ_MARKER();
                  
                  gmc_warp->duv[i].x = x;
                  gmc_warp->duv[i].y = y;
                  
                  //DPRINTF(XVID_DEBUG_HEADER,"sprite_warping_point[%i] xy=(%i,%i)\n", i, x, y);
               }
               
               if (sprite_brightness_change)
               {
                  /* XXX: brightness_change_factor() */
               }
               if (sprite_enable == SPRITE_STATIC)
               {
                  /* XXX: todo */
               }
               
            }
            
            if ((*quant = bs->GetBits(quant_bits)) < 1)  /* vop_quant */
               *quant = 1;
            DPRINTF(XVID_DEBUG_HEADER, "quant %i\n", *quant);
            
            if (coding_type != I_VOP) {
               *fcode_forward = bs->GetBits(3); /* fcode_forward */
               DPRINTF(XVID_DEBUG_HEADER, "fcode_forward %i\n", *fcode_forward);
            }
            
            if (coding_type == B_VOP) {
               *fcode_backward = bs->GetBits(3);   /* fcode_backward */
               DPRINTF(XVID_DEBUG_HEADER, "fcode_backward %i\n", *fcode_backward);
            }
            if(!scalability){
               if ((shape != VIDOBJLAY_SHAPE_RECTANGULAR) &&
                  (coding_type != I_VOP)) {
                  bs->Skip(1);   /* vop_shape_coding_type */
               }
            }
            return coding_type;
            
         }
         break;
      case USERDATA_START_CODE:
         {
            char tmp[256];
            int i;

            bs->Skip(32);  /* user_data_start_code */

            tmp[0] = bs->ShowBits(8);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -