📄 parset.c
字号:
int PicWidthInMbs, PicHeightInMapUnits, FrameHeightInMbs;
int width, height;
int nplane;
PicWidthInMbs = (sps->pic_width_in_mbs_minus1 +1);
PicHeightInMapUnits = (sps->pic_height_in_map_units_minus1 +1);
FrameHeightInMbs = ( 2 - sps->frame_mbs_only_flag ) * PicHeightInMapUnits;
width = PicWidthInMbs * MB_BLOCK_SIZE;
height = FrameHeightInMbs * MB_BLOCK_SIZE;
if( IS_INDEPENDENT(input) )
{
for( nplane=0; nplane<MAX_PLANE; nplane++ )
{
Co_located_JV[nplane] = alloc_colocated (width, height,sps->mb_adaptive_frame_field_flag);
}
}
else
{
Co_located = alloc_colocated (width, height,sps->mb_adaptive_frame_field_flag);
}
}
// Fidelity Range Extensions stuff
if(frext_profile)
{
sps->seq_scaling_matrix_present_flag = (Boolean) (input->ScalingMatrixPresentFlag&1);
n_ScalingList = (sps->chroma_format_idc != YUV444) ? 8 : 12;
for(i=0; i<n_ScalingList; i++)
{
if(i<6)
sps->seq_scaling_list_present_flag[i] = (input->ScalingListPresentFlag[i]&1);
else
{
if(input->Transform8x8Mode)
sps->seq_scaling_list_present_flag[i] = (input->ScalingListPresentFlag[i]&1);
else
sps->seq_scaling_list_present_flag[i] = 0;
}
if( sps->seq_scaling_matrix_present_flag == FALSE )
sps->seq_scaling_list_present_flag[i] = 0;
}
}
else
{
sps->seq_scaling_matrix_present_flag = FALSE;
for(i=0; i<12; i++)
sps->seq_scaling_list_present_flag[i] = 0;
}
if (img->auto_crop_right || img->auto_crop_bottom)
{
sps->frame_cropping_flag = TRUE;
sps->frame_cropping_rect_left_offset=0;
sps->frame_cropping_rect_top_offset=0;
sps->frame_cropping_rect_right_offset= (img->auto_crop_right / SubWidthC[sps->chroma_format_idc]);
sps->frame_cropping_rect_bottom_offset= (img->auto_crop_bottom / (SubHeightC[sps->chroma_format_idc] * (2 - sps->frame_mbs_only_flag)));
if (img->auto_crop_right % SubWidthC[sps->chroma_format_idc])
{
error("automatic frame cropping (width) not possible",500);
}
if (img->auto_crop_bottom % (SubHeightC[sps->chroma_format_idc] * (2 - sps->frame_mbs_only_flag)))
{
error("automatic frame cropping (height) not possible",500);
}
}
else
{
sps->frame_cropping_flag = FALSE;
}
}
/*!
************************************************************************
* \brief
* GeneratePictureParameterSet:
* Generates a Picture Parameter Set structure
*
* \par
* Regarding the QP
* The previous software versions coded the absolute QP only in the
* slice header. This is kept, and the offset in the PPS is coded
* even if we could save bits by intelligently using this field.
*
************************************************************************
*/
void GeneratePictureParameterSet( pic_parameter_set_rbsp_t *pps, //!< Picture Parameter Set to be filled
seq_parameter_set_rbsp_t *sps, //!< used Sequence Parameter Set
int PPS_id, //!< PPS ID
int WeightedPrediction, //!< value of weighted_pred_flag
int WeightedBiprediction, //!< value of weighted_bipred_idc
int cb_qp_index_offset, //!< value of cb_qp_index_offset
int cr_qp_index_offset //!< value of cr_qp_index_offset
)
{
unsigned i;
unsigned n_ScalingList;
int frext_profile = ((IdentifyProfile()==FREXT_HP) ||
(IdentifyProfile()==FREXT_Hi10P) ||
(IdentifyProfile()==FREXT_Hi422) ||
(IdentifyProfile()==FREXT_Hi444) ||
(IdentifyProfile()==FREXT_CAVLC444));
// *************************************************************************
// Picture Parameter Set
// *************************************************************************
pps->seq_parameter_set_id = sps->seq_parameter_set_id;
pps->pic_parameter_set_id = PPS_id;
pps->entropy_coding_mode_flag = (input->symbol_mode==UVLC ? FALSE : TRUE);
// Fidelity Range Extensions stuff
if(frext_profile)
{
pps->transform_8x8_mode_flag = (input->Transform8x8Mode ? TRUE:FALSE);
pps->pic_scaling_matrix_present_flag = (Boolean) ((input->ScalingMatrixPresentFlag&2)>>1);
n_ScalingList = (sps->chroma_format_idc != YUV444) ? 8 : 12;
for(i=0; i<n_ScalingList; i++)
{
if(i<6)
pps->pic_scaling_list_present_flag[i] = (input->ScalingListPresentFlag[i]&2)>>1;
else
{
if(pps->transform_8x8_mode_flag)
pps->pic_scaling_list_present_flag[i] = (input->ScalingListPresentFlag[i]&2)>>1;
else
pps->pic_scaling_list_present_flag[i] = 0;
}
if( pps->pic_scaling_matrix_present_flag == FALSE )
pps->pic_scaling_list_present_flag[i] = 0;
}
}
else
{
pps->pic_scaling_matrix_present_flag = FALSE;
for(i=0; i<12; i++)
pps->pic_scaling_list_present_flag[i] = 0;
pps->transform_8x8_mode_flag = FALSE;
input->Transform8x8Mode = 0;
}
// JVT-Fxxx (by Stephan Wenger, make this flag unconditional
pps->pic_order_present_flag = img->pic_order_present_flag;
// Begin FMO stuff
pps->num_slice_groups_minus1 = input->num_slice_groups_minus1;
//! Following set the parameter for different slice group types
if (pps->num_slice_groups_minus1 > 0)
{
if ((pps->slice_group_id = calloc ((sps->pic_height_in_map_units_minus1+1)*(sps->pic_width_in_mbs_minus1+1), sizeof(byte))) == NULL)
no_mem_exit ("GeneratePictureParameterSet: slice_group_id");
switch (input->slice_group_map_type)
{
case 0:
pps->slice_group_map_type = 0;
for(i=0; i<=pps->num_slice_groups_minus1; i++)
{
pps->run_length_minus1[i]=input->run_length_minus1[i];
}
break;
case 1:
pps->slice_group_map_type = 1;
break;
case 2:
// i loops from 0 to num_slice_groups_minus1-1, because no info for background needed
pps->slice_group_map_type = 2;
for(i=0; i<pps->num_slice_groups_minus1; i++)
{
pps->top_left[i] = input->top_left[i];
pps->bottom_right[i] = input->bottom_right[i];
}
break;
case 3:
case 4:
case 5:
pps->slice_group_map_type = input->slice_group_map_type;
pps->slice_group_change_direction_flag = (Boolean) input->slice_group_change_direction_flag;
pps->slice_group_change_rate_minus1 = input->slice_group_change_rate_minus1;
break;
case 6:
pps->slice_group_map_type = 6;
pps->pic_size_in_map_units_minus1 =
(((input->img_height+img->auto_crop_bottom)/MB_BLOCK_SIZE)/(2-sps->frame_mbs_only_flag))
*((input->img_width+img->auto_crop_right)/MB_BLOCK_SIZE) -1;
for (i=0;i<=pps->pic_size_in_map_units_minus1; i++)
pps->slice_group_id[i] = input->slice_group_id[i];
break;
default:
printf ("Parset.c: slice_group_map_type invalid, default\n");
assert (0==1);
}
}
// End FMO stuff
pps->num_ref_idx_l0_active_minus1 = sps->frame_mbs_only_flag ? (sps->num_ref_frames-1) : (2 * sps->num_ref_frames - 1) ; // set defaults
pps->num_ref_idx_l1_active_minus1 = sps->frame_mbs_only_flag ? (sps->num_ref_frames-1) : (2 * sps->num_ref_frames - 1) ; // set defaults
pps->weighted_pred_flag = (Boolean) WeightedPrediction;
pps->weighted_bipred_idc = WeightedBiprediction;
pps->pic_init_qp_minus26 = 0; // hard coded to zero, QP lives in the slice header
pps->pic_init_qs_minus26 = 0;
pps->chroma_qp_index_offset = cb_qp_index_offset;
if (frext_profile)
{
pps->cb_qp_index_offset = cb_qp_index_offset;
pps->cr_qp_index_offset = cr_qp_index_offset;
}
else
pps->cb_qp_index_offset = pps->cr_qp_index_offset = pps->chroma_qp_index_offset;
pps->deblocking_filter_control_present_flag = (Boolean) input->LFSendParameters;
pps->constrained_intra_pred_flag = (Boolean) input->UseConstrainedIntraPred;
// if redundant slice is in use.
pps->redundant_pic_cnt_present_flag = (Boolean) input->redundant_pic_flag;
}
/*!
*************************************************************************************
* \brief
* syntax for scaling list matrix values
*
* \param scalingListinput
* input scaling list
* \param scalingList
* scaling list to be used
* \param sizeOfScalingList
* size of the scaling list
* \param UseDefaultScalingMatrix
* usage of default Scaling Matrix
* \param bitstream
* target bitstream for writing syntax
*
* \return
* size of the RBSP in bytes
*
*************************************************************************************
*/
int Scaling_List(short *scalingListinput, short *scalingList, int sizeOfScalingList, short *UseDefaultScalingMatrix, Bitstream *bitstream)
{
int j, scanj;
int len=0;
int delta_scale, lastScale, nextScale;
lastScale = 8;
nextScale = 8;
for(j=0; j<sizeOfScalingList; j++)
{
scanj = (sizeOfScalingList==16) ? ZZ_SCAN[j]:ZZ_SCAN8[j];
if(nextScale!=0)
{
delta_scale = scalingListinput[scanj]-lastScale; // Calculate delta from the scalingList data from the input file
if(delta_scale>127)
delta_scale=delta_scale-256;
else if(delta_scale<-128)
delta_scale=delta_scale+256;
len+=se_v (" : delta_sl ", delta_scale, bitstream);
nextScale = scalingListinput[scanj];
*UseDefaultScalingMatrix|=(scanj==0 && nextScale==0); // Check first matrix value for zero
}
scalingList[scanj] = (short) ((nextScale==0) ? lastScale:nextScale); // Update the actual scalingList matrix with the correct values
lastScale = scalingList[scanj];
}
return len;
}
/*!
*************************************************************************************
* \brief
* int GenerateSeq_parameter_set_rbsp (seq_parameter_set_rbsp_t *sps, char *rbsp);
*
* \param sps
* sequence parameter structure
* \param rbsp
* buffer to be filled with the rbsp, size should be at least MAXIMUMPARSETRBSPSIZE
*
* \return
* size of the RBSP in bytes
*
* \note
* Sequence Parameter VUI function is called, but the function implements
* an exit (-1)
*************************************************************************************
*/
int GenerateSeq_parameter_set_rbsp (seq_parameter_set_rbsp_t *sps, byte *rbsp)
{
Bitstream *bitstream;
int len = 0, LenInBytes;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -