📄 header.c
字号:
return len;
}
/*!
************************************************************************
* \brief
* write the memory menagement control operations
************************************************************************
*/
static int dec_ref_pic_marking()
{
int dP_nr = assignSE2partition[input->partition_mode][SE_HEADER];
DataPartition *partition = &((img->currentSlice)->partArr[dP_nr]);
DecRefPicMarking_t *tmp_drpm;
int val, len=0;
if (img->currentPicture->idr_flag)
{
len += u_1("SH: no_output_of_prior_pics_flag", img->no_output_of_prior_pics_flag, partition);
len += u_1("SH: long_term_reference_flag", img->long_term_reference_flag, partition);
}
else
{
img->adaptive_ref_pic_buffering_flag = (img->dec_ref_pic_marking_buffer!=NULL);
len += u_1("SH: adaptive_ref_pic_buffering_flag", img->adaptive_ref_pic_buffering_flag, partition);
if (img->adaptive_ref_pic_buffering_flag)
{
tmp_drpm = img->dec_ref_pic_marking_buffer;
// write Memory Management Control Operation
do
{
if (tmp_drpm==NULL) error ("Error encoding MMCO commands", 500);
val = tmp_drpm->memory_management_control_operation;
len += ue_v("SH: memory_management_control_operation", val, partition);
if ((val==1)||(val==3))
{
len += 1 + ue_v("SH: difference_of_pic_nums_minus1", tmp_drpm->difference_of_pic_nums_minus1, partition);
}
if (val==2)
{
len+= ue_v("SH: long_term_pic_num", tmp_drpm->long_term_pic_num, partition);
}
if ((val==3)||(val==6))
{
len+= ue_v("SH: long_term_frame_idx", tmp_drpm->long_term_frame_idx, partition);
}
if (val==4)
{
len += ue_v("SH: max_long_term_pic_idx_plus1", tmp_drpm->max_long_term_frame_idx_plus1, partition);
}
tmp_drpm=tmp_drpm->Next;
} while (val != 0);
}
}
return len;
}
/*!
************************************************************************
* \brief
* write the memory menagement control operations
************************************************************************
*/
static int pred_weight_table()
{
int dP_nr = assignSE2partition[input->partition_mode][SE_HEADER];
DataPartition *partition = &((img->currentSlice)->partArr[dP_nr]);
int len = 0;
int i,j;
len += ue_v("SH: luma_log_weight_denom", luma_log_weight_denom, partition);
len += ue_v("SH: chroma_log_weight_denom", chroma_log_weight_denom, partition);
for (i=0; i< img->num_ref_idx_l0_active; i++)
{
if ( (wp_weight[0][i][0] != 1<<luma_log_weight_denom) || (wp_offset[0][i][0] != 0) )
{
len += u_1 ("SH: luma_weight_flag_l0", 1, partition);
len += se_v ("SH: luma_weight_l0", wp_weight[0][i][0], partition);
len += se_v ("SH: luma_offset_l0", wp_offset[0][i][0], partition);
}
else
{
len += u_1 ("SH: luma_weight_flag_l0", 0, partition);
}
if ( (wp_weight[0][i][1] != 1<<chroma_log_weight_denom) || (wp_offset[0][i][1] != 0) ||
(wp_weight[0][i][2] != 1<<chroma_log_weight_denom) || (wp_offset[0][i][2] != 0) )
{
len += u_1 ("chroma_weight_flag_l0", 1, partition);
for (j=1; j<3; j++)
{
len += se_v ("chroma_weight_l0", wp_weight[0][i][j] ,partition);
len += se_v ("chroma_offset_l0", wp_offset[0][i][j] ,partition);
}
}
else
{
len += u_1 ("chroma_weight_flag_l0", 0, partition);
}
}
if (img->type == B_SLICE)
{
for (i=0; i< img->num_ref_idx_l1_active; i++)
{
if ( (wp_weight[1][i][0] != 1<<luma_log_weight_denom) || (wp_offset[1][i][0] != 0) )
{
len += u_1 ("SH: luma_weight_flag_l1", 1, partition);
len += se_v ("SH: luma_weight_l1", wp_weight[1][i][0], partition);
len += se_v ("SH: luma_offset_l1", wp_offset[1][i][0], partition);
}
else
{
len += u_1 ("SH: luma_weight_flag_l1", 0, partition);
}
if ( (wp_weight[1][i][1] != 1<<chroma_log_weight_denom) || (wp_offset[1][i][1] != 0) ||
(wp_weight[1][i][2] != 1<<chroma_log_weight_denom) || (wp_offset[1][i][2] != 0) )
{
len += u_1 ("chroma_weight_flag_l1", 1, partition);
for (j=1; j<3; j++)
{
len += se_v ("chroma_weight_l1", wp_weight[1][i][j] ,partition);
len += se_v ("chroma_offset_l1", wp_offset[1][i][j] ,partition);
}
}
else
{
len += u_1 ("chroma_weight_flag_l1", 0, partition);
}
}
}
return len;
}
/********************************************************************************************
********************************************************************************************
*
* Local Support Functions
*
********************************************************************************************
********************************************************************************************/
// StW Note: This function is a hack. It would be cleaner if the encoder maintains
// the picture type in the given format. Note further that I have yet to understand
// why the encoder needs to know whether a picture is predicted from one or more
// reference pictures.
/*!
************************************************************************
* \brief
* Selects picture type and codes it to symbol
************************************************************************
*/
int get_picture_type()
{
// set this value to zero for transmission without signaling
// that the whole picture has the same slice type
int same_slicetype_for_whole_frame = 5;
switch (img->type)
{
case I_SLICE:
return 2 + same_slicetype_for_whole_frame;
break;
case P_SLICE:
return 0 + same_slicetype_for_whole_frame;
break;
case B_SLICE:
return 1 + same_slicetype_for_whole_frame;
break;
case SP_SLICE:
return 3 + same_slicetype_for_whole_frame;
break;
default:
error("Picture Type not supported!",1);
break;
}
return 0;
}
/*!
*****************************************************************************
*
* \brief
* int Partition_BC_Header () write the Partition type B, C header
*
* \return
* Number of bits used by the partition header
*
* \para Parameters
* PartNo: Partition Number to which the header should be written
*
* \para Side effects
* Partition header as per VCEG-N72r2 is written into the appropriate
* partition bit buffer
*
* \para Limitations/Shortcomings/Tweaks
* The current code does not support the change of picture parameters within
* one coded sequence, hence there is only one parameter set necessary. This
* is hard coded to zero.
*
* \para
* Note: this is still the old Partition_BC_Header and not yet compliant with
* the spec.
*
* \date
* October 24, 2001
*
* \author
* Stephan Wenger stewe@cs.tu-berlin.de
*****************************************************************************/
int Partition_BC_Header(int PartNo)
{
DataPartition *partition = &((img->currentSlice)->partArr[PartNo]);
SyntaxElement symbol, *sym = &symbol;
int len = 0;
assert (input->of_mode == PAR_OF_RTP);
assert (PartNo > 0 && PartNo < img->currentSlice->max_part_nr);
sym->type = SE_HEADER; // This will be true for all symbols generated here
sym->mapping = ue_linfo; // Mapping rule: Simple code number to len/info
SYMTRACESTRING("RTP-PH: Picture ID");
sym->value1 = img->currentSlice->picture_id;
len += writeSyntaxElement_UVLC (sym, partition);
SYMTRACESTRING("RTP-PH: Slice ID");
sym->value1 = img->current_slice_nr;
len += writeSyntaxElement_UVLC (sym, partition);
return len;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -