void H264VideoStreamParser::analyze_hrd_parameters(BitVector& bv) {
  DEBUG_STR("BEGIN hrd_parameters");
  unsigned cpb_cnt_minus1 = bv.get_expGolomb();
  DEBUG_PRINT(cpb_cnt_minus1);
  unsigned bit_rate_scale = bv.getBits(4);
  DEBUG_PRINT(bit_rate_scale);
  unsigned cpb_size_scale = bv.getBits(4);
  DEBUG_PRINT(cpb_size_scale);
  for (unsigned SchedSelIdx = 0; SchedSelIdx <= cpb_cnt_minus1; ++SchedSelIdx) {
    DEBUG_TAB;
    unsigned bit_rate_value_minus1 = bv.get_expGolomb();
    DEBUG_PRINT(bit_rate_value_minus1);
    unsigned cpb_size_value_minus1 = bv.get_expGolomb();
    DEBUG_PRINT(cpb_size_value_minus1);
    unsigned cbr_flag = bv.get1Bit();
    DEBUG_PRINT(cbr_flag);
  }
  unsigned initial_cpb_removal_delay_length_minus1 = bv.getBits(5);
  DEBUG_PRINT(initial_cpb_removal_delay_length_minus1);
  unsigned cpb_removal_delay_length_minus1 = bv.getBits(5);
  DEBUG_PRINT(cpb_removal_delay_length_minus1);
  unsigned dpb_output_delay_length_minus1 = bv.getBits(5);
  DEBUG_PRINT(dpb_output_delay_length_minus1);
  unsigned time_offset_length = bv.getBits(5);
  DEBUG_PRINT(time_offset_length);
  DEBUG_STR("END hrd_parameters");
}
示例#2
0
/* do the huffman-decoding 						*/
static int rsf_huffman_decoder(BitVector& bv,
		struct huffcodetab const* h, // ptr to huffman code record
			/* unsigned */ int *x, // returns decoded x value
			/* unsigned */ int *y,  // returns decoded y value
			       int* v, int* w) {
  HUFFBITS level;
  unsigned point = 0;
  int error = 1;
  level     = dmask;
  *x = *y = *v = *w = 0;
  if (h->val == NULL) return 2;

  /* table 0 needs no bits */
  if (h->treelen == 0) return 0;

  /* Lookup in Huffman table. */

  do {
    if (h->val[point][0]==0) {   /*end of tree*/
      *x = h->val[point][1] >> 4;
      *y = h->val[point][1] & 0xf;

      error = 0;
      break;
    }
    if (bv.get1Bit()) {
      while (h->val[point][1] >= MXOFF) point += h->val[point][1];
      point += h->val[point][1];
    }
    else {
      while (h->val[point][0] >= MXOFF) point += h->val[point][0];
      point += h->val[point][0];
    }
    level >>= 1;
  } while (level  || (point < h->treelen) );
void H264VideoStreamParser
::analyze_vui_parameters(BitVector& bv,
			 unsigned& num_units_in_tick, unsigned& time_scale, unsigned& fixed_frame_rate_flag) {
  DEBUG_STR("BEGIN vui_parameters");
  unsigned aspect_ratio_info_present_flag = bv.get1Bit();
  DEBUG_PRINT(aspect_ratio_info_present_flag);
  if (aspect_ratio_info_present_flag) {
    DEBUG_TAB;
    unsigned aspect_ratio_idc = bv.getBits(8);
    DEBUG_PRINT(aspect_ratio_idc);
    if (aspect_ratio_idc == 255/*Extended_SAR*/) {
      bv.skipBits(32); // sar_width; sar_height
    }
  }
  unsigned overscan_info_present_flag = bv.get1Bit();
  DEBUG_PRINT(overscan_info_present_flag);
  if (overscan_info_present_flag) {
    bv.skipBits(1); // overscan_appropriate_flag
  }
  unsigned video_signal_type_present_flag = bv.get1Bit();
  DEBUG_PRINT(video_signal_type_present_flag);
  if (video_signal_type_present_flag) {
    DEBUG_TAB;
    bv.skipBits(4); // video_format; video_full_range_flag
    unsigned colour_description_present_flag = bv.get1Bit();
    DEBUG_PRINT(colour_description_present_flag);
    if (colour_description_present_flag) {
      bv.skipBits(24); // colour_primaries; transfer_characteristics; matrix_coefficients
    }
  }
  unsigned chroma_loc_info_present_flag = bv.get1Bit();
  DEBUG_PRINT(chroma_loc_info_present_flag);
  if (chroma_loc_info_present_flag) {
    (void)bv.get_expGolomb(); // chroma_sample_loc_type_top_field
    (void)bv.get_expGolomb(); // chroma_sample_loc_type_bottom_field
  }
  unsigned timing_info_present_flag = bv.get1Bit();
  DEBUG_PRINT(timing_info_present_flag);
  if (timing_info_present_flag) {
    DEBUG_TAB;
    num_units_in_tick = bv.getBits(32);
    DEBUG_PRINT(num_units_in_tick);
    time_scale = bv.getBits(32);
    DEBUG_PRINT(time_scale);
    fixed_frame_rate_flag = bv.get1Bit();
    DEBUG_PRINT(fixed_frame_rate_flag);
  }
#ifdef DO_FULL_SPS_PARSING
  unsigned nal_hrd_parameters_present_flag = bv.get1Bit();
  DEBUG_PRINT(nal_hrd_parameters_present_flag);
  if (nal_hrd_parameters_present_flag) {
    DEBUG_TAB;
    analyze_hrd_parameters(bv);
  }
  unsigned vcl_hrd_parameters_present_flag = bv.get1Bit();
  DEBUG_PRINT(vcl_hrd_parameters_present_flag);
  if (vcl_hrd_parameters_present_flag) {
    DEBUG_TAB;
    analyze_hrd_parameters(bv);
  }
  if (nal_hrd_parameters_present_flag || vcl_hrd_parameters_present_flag) {
    bv.skipBits(1); // low_delay_hrd_flag
  }
  bv.skipBits(1); // pic_struct_present_flag
  unsigned bitstream_restriction_flag = bv.get1Bit();
  DEBUG_PRINT(bitstream_restriction_flag);
  if (bitstream_restriction_flag) {
    bv.skipBits(1); // motion_vectors_over_pic_boundaries_flag
    (void)bv.get_expGolomb(); // max_bytes_per_pic_denom
    (void)bv.get_expGolomb(); // max_bits_per_mb_denom
    (void)bv.get_expGolomb(); // log2_max_mv_length_horizontal
    (void)bv.get_expGolomb(); // log2_max_mv_length_vertical
    (void)bv.get_expGolomb(); // num_reorder_frames
    (void)bv.get_expGolomb(); // max_dec_frame_buffering
  }
  DEBUG_STR("END vui_parameters");
#endif
}