📄 parset.c
字号:
len+=u_1 ("SPS: frame_cropping_flag", sps->frame_cropping_flag, partition);
if (sps->frame_cropping_flag)
{
len+=ue_v ("SPS: frame_cropping_rect_left_offset", sps->frame_cropping_rect_left_offset, partition);
len+=ue_v ("SPS: frame_cropping_rect_right_offset", sps->frame_cropping_rect_right_offset, partition);
len+=ue_v ("SPS: frame_cropping_rect_top_offset", sps->frame_cropping_rect_top_offset, partition);
len+=ue_v ("SPS: frame_cropping_rect_bottom_offset", sps->frame_cropping_rect_bottom_offset, partition);
}
len+=u_1 ("SPS: vui_parameters_present_flag", sps->vui_parameters_present_flag, partition);
if (sps->vui_parameters_present_flag)
len+=GenerateVUISequenceParameters(partition); // currently a dummy, asserting
SODBtoRBSP(partition->bitstream); // copies the last couple of bits into the byte buffer
LenInBytes=partition->bitstream->byte_pos;
free (partition->bitstream);
free (partition);
return LenInBytes;
}
/*!
*************************************************************************************
* \brief
* int GeneratePic_parameter_set_rbsp (pic_parameter_set_rbsp_t *sps, char *rbsp);
*
* \param pps
* picture parameter structure
* \param rbsp
* buffer to be filled with the rbsp, size should be at least MAXIMUMPARSETRBSPSIZE
*
* \return
* size of the RBSP in bytes, negative in case of an error
*
* \note
* Picture Parameter VUI function is called, but the function implements
* an exit (-1)
*************************************************************************************
*/
int GeneratePic_parameter_set_rbsp (pic_parameter_set_rbsp_t *pps, char *rbsp)
{
DataPartition *partition;
int len = 0, LenInBytes;
unsigned i;
unsigned NumberBitsPerSliceGroupId;
int profile_idc;
assert (rbsp != NULL);
// In order to use the entropy coding functions from golomb.c we need
// to allocate a partition structure. It will be freed later in this
// function
if ((partition=calloc(1,sizeof(DataPartition)))==NULL) no_mem_exit("PicParameterSet:partition");
if ((partition->bitstream=calloc(1, sizeof(Bitstream)))==NULL) no_mem_exit("PicParameterSet:bitstream");
// .. and use the rbsp provided (or allocated above) for the data
partition->bitstream->streamBuffer = rbsp;
partition->bitstream->bits_to_go = 8;
//sw paff
pps->pic_order_present_flag = img->pic_order_present_flag;
len+=ue_v ("PPS: pic_parameter_set_id", pps->pic_parameter_set_id, partition);
len+=ue_v ("PPS: seq_parameter_set_id", pps->seq_parameter_set_id, partition);
len+=u_1 ("PPS: entropy_coding_mode_flag", pps->entropy_coding_mode_flag, partition);
len+=u_1 ("PPS: pic_order_present_flag", pps->pic_order_present_flag, partition);
len+=ue_v ("PPS: num_slice_groups_minus1", pps->num_slice_groups_minus1, partition);
// FMO stuff
if(pps->num_slice_groups_minus1 > 0 )
{
len+=ue_v ("PPS: slice_group_map_type", pps->slice_group_map_type, partition);
if (pps->slice_group_map_type == 0)
for (i=0; i<=pps->num_slice_groups_minus1; i++)
len+=ue_v ("PPS: run_length_minus1[i]", pps->run_length_minus1[i], partition);
else if (pps->slice_group_map_type==2)
for (i=0; i<pps->num_slice_groups_minus1; i++)
{
len+=ue_v ("PPS: top_left[i]", pps->top_left[i], partition);
len+=ue_v ("PPS: bottom_right[i]", pps->bottom_right[i], partition);
}
else if (pps->slice_group_map_type == 3 ||
pps->slice_group_map_type == 4 ||
pps->slice_group_map_type == 5)
{
len+=u_1 ("PPS: slice_group_change_direction_flag", pps->slice_group_change_direction_flag, partition);
len+=ue_v ("PPS: slice_group_change_rate_minus1", pps->slice_group_change_rate_minus1, partition);
}
else if (pps->slice_group_map_type == 6)
{
if (pps->num_slice_groups_minus1>=4)
NumberBitsPerSliceGroupId=3;
else if (pps->num_slice_groups_minus1>=2)
NumberBitsPerSliceGroupId=2;
else if (pps->num_slice_groups_minus1>=1)
NumberBitsPerSliceGroupId=1;
else
NumberBitsPerSliceGroupId=0;
len+=ue_v ("PPS: pic_size_in_map_units_minus1", pps->pic_size_in_map_units_minus1, partition);
for(i=0; i<=pps->pic_size_in_map_units_minus1; i++)
len+= u_v (NumberBitsPerSliceGroupId, "PPS: >slice_group_id[i]", pps->slice_group_id[i], partition);
}
}
// End of FMO stuff
len+=ue_v ("PPS: num_ref_idx_l0_active_minus1", pps->num_ref_idx_l0_active_minus1, partition);
len+=ue_v ("PPS: num_ref_idx_l1_active_minus1", pps->num_ref_idx_l1_active_minus1, partition);
len+=u_1 ("PPS: weighted_pred_flag", pps->weighted_pred_flag, partition);
len+=u_v (2, "PPS: weighted_bipred_idc", pps->weighted_bipred_idc, partition);
len+=se_v ("PPS: pic_init_qp_minus26", pps->pic_init_qp_minus26, partition);
len+=se_v ("PPS: pic_init_qs_minus26", pps->pic_init_qs_minus26, partition);
profile_idc = IdentifyProfile();
if((profile_idc==FREXT_HP) ||
(profile_idc==FREXT_Hi10P) ||
(profile_idc==FREXT_Hi422) ||
(profile_idc==FREXT_Hi444))
len+=se_v ("PPS: chroma_qp_index_offset", pps->cb_qp_index_offset, partition);
else
len+=se_v ("PPS: chroma_qp_index_offset", pps->chroma_qp_index_offset, partition);
len+=u_1 ("PPS: deblocking_filter_control_present_flag", pps->deblocking_filter_control_present_flag, partition);
len+=u_1 ("PPS: constrained_intra_pred_flag", pps->constrained_intra_pred_flag, partition);
len+=u_1 ("PPS: redundant_pic_cnt_present_flag", pps->redundant_pic_cnt_present_flag, partition);
// Fidelity Range Extensions stuff
if((profile_idc==FREXT_HP) ||
(profile_idc==FREXT_Hi10P) ||
(profile_idc==FREXT_Hi422) ||
(profile_idc==FREXT_Hi444))
{
len+=u_1 ("PPS: transform_8x8_mode_flag", pps->transform_8x8_mode_flag, partition);
len+=u_1 ("PPS: pic_scaling_matrix_present_flag", pps->pic_scaling_matrix_present_flag, partition);
if(pps->pic_scaling_matrix_present_flag)
{
for(i=0; i<(6+((unsigned)pps->transform_8x8_mode_flag<<1)); i++)
{
len+=u_1 ("PPS: pic_scaling_list_present_flag", pps->pic_scaling_list_present_flag[i], partition);
if(pps->pic_scaling_list_present_flag[i])
{
if(i<6)
len+=Scaling_List(ScalingList4x4input[i], ScalingList4x4[i], 16, &UseDefaultScalingMatrix4x4Flag[i], partition);
else
len+=Scaling_List(ScalingList8x8input[i-6], ScalingList8x8[i-6], 64, &UseDefaultScalingMatrix8x8Flag[i-6], partition);
}
}
}
len+=se_v ("PPS: second_chroma_qp_index_offset", pps->cr_qp_index_offset, partition);
}
SODBtoRBSP(partition->bitstream); // copies the last couple of bits into the byte buffer
LenInBytes=partition->bitstream->byte_pos;
// Get rid of the helper structures
free (partition->bitstream);
free (partition);
return LenInBytes;
}
/*!
*************************************************************************************
* \brief
* Returns the Profile
*
* \return
* Profile according to Annex A
*
* \note
* Function is currently a dummy. Should "calculate" the profile from those
* config file parameters. E.g.
*
* Profile = Baseline;
* if (CABAC Used || Interlace used) Profile=Main;
* if (!Cabac Used) && (Bframes | SPframes) Profile = Streaming;
*
*************************************************************************************
*/
int IdentifyProfile()
{
return input->ProfileIDC;
};
/*!
*************************************************************************************
* \brief
* Returns the Level
*
* \return
* Level according to Annex A
*
* \note
* This function is currently a dummy, but should calculate the level out of
* the config file parameters (primarily the picture size)
*************************************************************************************
*/
int IdentifyLevel()
{
return input->LevelIDC;
};
/*!
*************************************************************************************
* \brief
* Returns the number of reference frame buffers
*
* \return
* Number of reference frame buffers used
*
* \note
* This function currently maps to input->num_ref_frames. With all this interlace
* stuff this may or may not be correct. If you determine a problem with the
* memory management for Interlace, then this could be one possible problem.
* However, so far no problem have been determined by my limited testing of
* a stupid 1950's technology :-) StW, 11/27/02
*************************************************************************************
*/
int IdentifyNumRefFrames()
{
if(input->num_ref_frames > 16)error("no ref frames too large",-100);
return input->num_ref_frames;
}
/*!
*************************************************************************************
* \brief
* Function body for VUI Parameter generation (to be done)
*
* \return
* exits with error message
*************************************************************************************
*/
static int GenerateVUISequenceParameters(DataPartition *partition)
{
int len=0;
// special case to signal the RGB format
if(input->rgb_input_flag && input->yuv_format==3)
{
//still pretty much a dummy VUI
printf ("test: writing Sequence Parameter VUI to signal RGB format\n");
len+=u_1 ("VUI: aspect_ratio_info_present_flag", 0, partition);
len+=u_1 ("VUI: overscan_info_present_flag", 0, partition);
len+=u_1 ("VUI: video_signal_type_present_flag", 1, partition);
len+=u_v (3, "VUI: video format", 2, partition);
len+=u_1 ("VUI: video_full_range_flag", 1, partition);
len+=u_1 ("VUI: color_description_present_flag", 1, partition);
len+=u_v (8, "VUI: colour primaries", 2, partition);
len+=u_v (8, "VUI: transfer characteristics", 2, partition);
len+=u_v (8, "VUI: matrix coefficients", 0, partition);
len+=u_1 ("VUI: chroma_loc_info_present_flag", 0, partition);
len+=u_1 ("VUI: timing_info_present_flag", 0, partition);
len+=u_1 ("VUI: nal_hrd_parameters_present_flag", 0, partition);
len+=u_1 ("VUI: vcl_hrd_parameters_present_flag", 0, partition);
len+=u_1 ("VUI: pic_struc_present_flag", 0, partition);
len+=u_1 ("VUI: bitstream_restriction_flag", 0, partition);
return len;
}
else
{
printf ("Sequence Parameter VUI not yet implemented, this should never happen, exit\n");
exit (-1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -