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

📄 parameterset.c

📁 Nokia H.264/AVC Encoder/Decoder Usage Manual
💻 C
📖 第 1 页 / 共 2 页
字号:
  bits += u_n( bitbuf, pps->weighted_bipred_idc, 2);  bits += se_v( bitbuf, pps->pic_init_qp_minus26 );  bits += se_v( bitbuf, pps->pic_init_qs_minus26 );  bits += se_v( bitbuf, pps->chroma_qp_index_offset );  bits += u_n( bitbuf, pps->deblocking_filter_parameters_present_flag, 1 );  bits += u_n( bitbuf, pps->constrained_intra_pred_flag, 1 );  bits += u_n( bitbuf, pps->redundant_pic_cnt_present_flag, 1 );  bits += bibTrailingBits(bitbuf);    return bits;}/* * psValidateSliceParams: * * Parameters: *      param                 Encoding parameters *       * Function: *      Validate the slice related members in encParams_s structure. * * Returns: *      - */void psValidateSliceParams(encParams_s *param){  int i;  int widthMb, heightMb, totalMbs;  widthMb  = param->picWidth/16;  heightMb = param->picHeight/16;  totalMbs = widthMb * heightMb;  param->sgmType  = clip(0, 6, param->sgmType);  param->sgmCount = clip(1, 8, param->sgmCount);  if (param->sgmCount > 1)  {    if (param->sgmType == SLICE_MAP_INTERLEAVED)    {      int totalMbsThisType;      // numSgmParams has run-length, # of parameters should match sgmCount      param->sgmCount = min(param->sgmCount, param->numSgmParams);      for (totalMbsThisType = 0, i = 0; i < param->sgmCount; i ++)      {        param->sgmParams[i] = clip(1, totalMbs, param->sgmParams[i]);        totalMbsThisType += param->sgmParams[i];      }      if (totalMbsThisType >= totalMbs)        param->sgmCount = 1;    }    else if (param->sgmType == SLICE_MAP_FOREGROUND)    {      param->sgmCount = min(param->sgmCount, param->numSgmParams/2 + 1);      // the last slice is the background      for (i = 0; i < param->sgmCount - 1; i ++)      {        int mbX0, mbY0, mbX1, mbY1;        if ((param->sgmParams[2 * i] >= totalMbs) ||          (param->sgmParams[2 * i + 1] >= totalMbs))          break;        // the rectangles should be correctly defined        mbX0 = param->sgmParams[2 * i] % widthMb;        mbY0 = param->sgmParams[2 * i] / widthMb;        mbX1 = param->sgmParams[2 * i + 1] % widthMb;        mbY1 = param->sgmParams[2 * i + 1] / widthMb;        if ((mbX0 > mbX1) || (mbY0 > mbY1))          break;      }      param->sgmCount = ((i > 0) ? i : 0) + 1;    }    else if ((param->sgmType >= SLICE_MAP_BOX_OUT) &&       (param->sgmType <= SLICE_MAP_WIPE))    {      if (param->numSgmParams < 2)      {        param->sgmParams[0] = 0;     // slice_group_change_direction_flag        param->sgmParams[1] = 4;     // slice_group_change_rate_minus1      }      else      {        param->sgmParams[0] = clip(0, 1, param->sgmParams[0]);        param->sgmParams[1] = clip(1, totalMbs, param->sgmParams[1]);      }    }  }}/* * psFillParameterSetStructures: * * Parameters: *      sps                   Sequence parameter set *      pps                   Picture parameter set *      param                 Encoding parameters *       * Function: *      Generates a picture and sequence parameter set structures. *      Many values are current hard-coded to defaults, especially most of the *      VUI stuff. * *      Limitations: *      Currently, the encoder does not support multiple parameter sets, *      primarily because the config file does not support it.  Hence the *      pic_parameter_set_id and the seq_parameter_set_id are always zero. *      If one day multiple parameter sets are implemented, it would *      make sense to break this function into two, one for the picture and *      one for the sequence. * * Returns: *      - */void psFillParameterSetStructures(seq_parameter_set_s *sps,                                  pic_parameter_set_s *pps,                                  encParams_s         *param){  int i;  vui_parameters_s    *vui;  // *************************************************************************  // Sequence Parameter Set  // *************************************************************************    sps->level_idc   = param->level;  /* Baseline and Extended profile decoder can only decode CAVLC */  if (param->entropyEncoder == ENTROPY_CAVLC) {    sps->profile_idc          = PS_BASELINE_PROFILE_IDC;    sps->constraint_set0_flag = 1;     /* Stream is Baseline compliant */    sps->constraint_set2_flag = 1;     /* Stream is Extended Profile compliant */  }  else {    sps->profile_idc          = PS_MAIN_PROFILE_IDC;    sps->constraint_set0_flag = 0;     /* Stream is not Baseline compliant */    sps->constraint_set0_flag = 0;     /* Stream is not Extended Profile compliant */  }  /* Main profile decoder supports only 1 slice group */  if (param->sgmCount == 1)    sps->constraint_set1_flag = 1;     /* Stream is Main Profile compliant */  else    sps->constraint_set1_flag = 0;     /* Stream is not Main Profile compliant */  sps->reserved_zero_5bits  = 0;  // Parameter Set ID hardcoded to zero  sps->seq_parameter_set_id = 0;  /* POC stuff: */  sps->log2_max_frame_num_minus4 = param->log2_max_frame_num_minus4;  sps->pic_order_cnt_type = 0;          // testing poc type 2  if (sps->pic_order_cnt_type == 0)   {    sps->log2_max_pic_order_cnt_lsb_minus4 =       param->log2_max_pic_order_cnt_lsb_minus4;  }  else if (sps->pic_order_cnt_type == 1) {    /* The parameters are hard coded */    sps->delta_pic_order_always_zero_flag = 1;    sps->offset_for_non_ref_pic = 0;    sps->offset_for_top_to_bottom_field = 0;    sps->num_ref_frames_in_pic_order_cnt_cycle = 1;    sps->offset_for_ref_frame[0] = param->offsetForRefFrame;  }  // End of POC stuff  sps->num_ref_frames = param->maxNumRefFrms;  sps->gaps_in_frame_num_value_allowed_flag = 0;  sps->frame_mbs_only_flag = 1;  // Picture size, finally a simple one :-)  sps->pic_width_in_mbs_minus1 = (param->picWidth/16) -1;  sps->pic_height_in_map_units_minus1 =     ((param->picHeight/16)/ (2 - sps->frame_mbs_only_flag)) - 1;  /* We don't use interlace, put 0 here */  sps->mb_adaptive_frame_field_flag = 0;  /* Has no meaning for Baseline, must be 1 for some Main Profile levels */  sps->direct_8x8_inference_flag = 1;    sps->frame_cropping_flag = 0;  if ((param->cropOffsets[0] > 0) || (param->cropOffsets[1] > 0) ||     (param->cropOffsets[2] > 0) || (param->cropOffsets[3] > 0))  {    sps->frame_cropping_flag = 1;    sps->frame_crop_left_offset = param->cropOffsets[0] >> 1;    sps->frame_crop_right_offset = param->cropOffsets[1] >> 1;    sps->frame_crop_top_offset = param->cropOffsets[2] >> 1;    sps->frame_crop_bottom_offset = param->cropOffsets[3] >> 1;  }  sps->vui_parameters_present_flag = 1;    // *************************************************************************    // VUI parameters: Set the default values here    // *************************************************************************    vui = &sps->vui_parameters;    vui->aspect_ratio_info_present_flag = 0;    vui->overscan_info_present_flag = 0;    vui->video_signal_type_present_flag = 0;    vui->chroma_loc_info_present_flag = 0;    if (param->origFpsTimes1000 != 0) {      vui->timing_info_present_flag = 1;      // We are assuming field_pic_lag == 0 -> divide by 2      vui->num_units_in_tick = (param->offsetForRefFrame)*1000;      vui->time_scale = param->origFpsTimes1000;      vui->fixed_frame_rate_flag = 1;           // Always fixed frame rate    }    else      vui->timing_info_present_flag = 0;  if(param->useSEIMessages)    vui->nal_hrd_parameters_present_flag = 1;  else    vui->nal_hrd_parameters_present_flag = 0;  if(param->useSEIMessages)    vui->vcl_hrd_parameters_present_flag = 1;  else    vui->vcl_hrd_parameters_present_flag = 0;    vui->pic_struct_present_flag = 0;    /* Write bitstream restriction parameters (mainly to restrict DPB size) */    vui->bitstream_restriction_flag = 1;    vui->motion_vectors_over_pic_boundaries_flag = 1;    vui->max_bytes_per_pic_denom = 0;    vui->max_bits_per_mb_denom = 0;    vui->log2_max_mv_length_horizontal = 11; /* max. mv horizontal component is [-2048, 2047] */    vui->log2_max_mv_length_vertical   = 11; /* max. mv vertical component is [-2048, 2047] */    vui->num_reorder_frames = param->numReorderFrames;    vui->max_dec_frame_buffering = param->maxNumRefFrms;  /* Set DPB size */  // *************************************************************************  // Picture Parameter Set   // *************************************************************************  pps->seq_parameter_set_id = 0;  pps->pic_parameter_set_id = 0;  pps->entropy_coding_mode_flag = param->entropyEncoder;  pps->pic_order_present_flag = 0;    /* DT: check. Always be zero, because no bottom field POC is needed */  pps->num_slice_groups_minus1 = param->sgmCount - 1;  pps->slice_group_map_type    = param->sgmType;  if (pps->num_slice_groups_minus1 > 0) {    if (pps->slice_group_map_type == SLICE_MAP_INTERLEAVED) {      // interleaved, run-length      for (i = 0; i < param->sgmCount; i ++)        pps->run_length_minus1[i] = param->sgmParams[i] - 1;    }    // dispersed, no parameter needed    else if (pps->slice_group_map_type == SLICE_MAP_FOREGROUND) {      for (i = 0; i < param->sgmCount; i ++) {        pps->top_left[i]     = param->sgmParams[2 * i];        pps->bottom_right[i] = param->sgmParams[2 * i + 1];      }    }    else if ((pps->slice_group_map_type >= SLICE_MAP_BOX_OUT) &&       (pps->slice_group_map_type <= SLICE_MAP_WIPE)) {      pps->slice_group_change_direction_flag = param->sgmParams[0];      pps->slice_group_change_rate_minus1    = param->sgmParams[1] - 1;    }    else if (pps->slice_group_map_type == SLICE_MAP_BITMAP) {      pps->pic_size_in_map_units_minus1 = (sps->pic_width_in_mbs_minus1 + 1) *        (sps->pic_height_in_map_units_minus1 + 1) - 1;      pps->slice_group_id = (int8 *)        nccMalloc((pps->pic_size_in_map_units_minus1 + 1) * sizeof(int8));      for (i = 0; i < (int) pps->pic_size_in_map_units_minus1; i++)        pps->slice_group_id[i] = (int8) (i % (pps->num_slice_groups_minus1 + 1));    }  }  pps->num_ref_idx_l0_active_minus1 = max(0, param->maxNumRefFrms - 1);   // DT: check  pps->num_ref_idx_l1_active_minus1 = 0;    pps->weighted_pred_flag = 0;  pps->weighted_bipred_idc = 0;  pps->pic_init_qp_minus26 = param->qpInter - 26;  pps->pic_init_qs_minus26 = 0;  pps->chroma_qp_index_offset = param->chromaQpIdx;      // double check: is this chroma fidelity thing already implemented???  pps->deblocking_filter_parameters_present_flag = 1;   // TODO: checking deblocking filter  pps->constrained_intra_pred_flag = param->constIpred;    pps->redundant_pic_cnt_present_flag = 0;  // must be 0 because redundant_pictures_allowed_flag is set to 0}/* * psCloseParameterSet: *      free the sequence parameter set * * Parameters: *      sps                   the sequence parameter set to be freed * * Returns: *      - */void psCloseParameterSet(pic_parameter_set_s *pps){  if (pps->num_slice_groups_minus1 > 0 && pps->slice_group_map_type == 6)    nccFree(pps->slice_group_id);}

⌨️ 快捷键说明

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