?? h.264
字號:
void DumpSPS (seq_parameter_set_rbsp_t *sps)
{
printf ("Dumping a sequence parset, to be implemented\n");
};
void DumpPPS (pic_parameter_set_rbsp_t *pps)
{
printf ("Dumping a picture parset, to be implemented\n");
}
void PPSConsistencyCheck (pic_parameter_set_rbsp_t *pps)
{
printf ("Consistency checking a picture parset, to be implemented\n");
// if (pps->seq_parameter_set_id invalid then do something)
}
void SPSConsistencyCheck (seq_parameter_set_rbsp_t *sps)
{
printf ("Consistency checking a sequence parset, to be implemented\n");
}
void MakePPSavailable (int id, pic_parameter_set_rbsp_t *pps)
{
assert (pps->Valid == TRUE);
if (PicParSet[id].Valid == TRUE && PicParSet[id].slice_group_id != NULL)
free (PicParSet[id].slice_group_id);
memcpy (&PicParSet[id], pps, sizeof (pic_parameter_set_rbsp_t));
if ((PicParSet[id].slice_group_id = calloc (PicParSet[id].num_slice_group_map_units_minus1+1, sizeof(int))) == NULL)
no_mem_exit ("MakePPSavailable: Cannot calloc slice_group_id");
memcpy (PicParSet[id].slice_group_id, pps->slice_group_id, (pps->num_slice_group_map_units_minus1+1)*sizeof(int));
}
void MakeSPSavailable (int id, seq_parameter_set_rbsp_t *sps)
{
assert (sps->Valid == TRUE);
memcpy (&SeqParSet[id], sps, sizeof (seq_parameter_set_rbsp_t));
}
void ProcessSPS (NALU_t *nalu)
{
DataPartition *dp = AllocPartition(1);
seq_parameter_set_rbsp_t *sps = AllocSPS();
int dummy;
memcpy (dp->bitstream->streamBuffer, &nalu->buf[1], nalu->len-1);
dp->bitstream->code_len = dp->bitstream->bitstream_length = RBSPtoSODB (dp->bitstream->streamBuffer, nalu->len-1);
dp->bitstream->ei_flag = 0;
dp->bitstream->read_len = dp->bitstream->frame_bitoffset = 0;
dummy = InterpretSPS (dp, sps);
// DumpSPS (sps);
// SPSConsistencyCheck (pps);
MakeSPSavailable (sps->seq_parameter_set_id, sps);
FreePartition (dp, 1);
FreeSPS (sps);
}
void ProcessPPS (NALU_t *nalu)
{
DataPartition *dp;
pic_parameter_set_rbsp_t *pps;
int dummy;
dp = AllocPartition(1);
pps = AllocPPS();
memcpy (dp->bitstream->streamBuffer, &nalu->buf[1], nalu->len-1);
dp->bitstream->code_len = dp->bitstream->bitstream_length = RBSPtoSODB (dp->bitstream->streamBuffer, nalu->len-1);
dp->bitstream->ei_flag = 0;
dp->bitstream->read_len = dp->bitstream->frame_bitoffset = 0;
dummy = InterpretPPS (dp, pps);
// DumpPPS (pps);
// PPSConsistencyCheck (pps);
MakePPSavailable (pps->pic_parameter_set_id, pps);
FreePartition (dp, 1);
FreePPS (pps);
}
void UseParameterSet (int PicParsetId)
{
seq_parameter_set_rbsp_t *sps = &SeqParSet[PicParSet[PicParsetId].seq_parameter_set_id];
pic_parameter_set_rbsp_t *pps = &PicParSet[PicParsetId];
static unsigned int ExpectedDeltaPerPicOrderCntCycle; // POC200301 Can it be deleted?
int i;
if (PicParSet[PicParsetId].Valid != TRUE)
printf ("Trying to use an invalid (uninitialized) Picture Parameter Set with ID %d, expect the unexpected...\n", PicParsetId);
if (SeqParSet[PicParSet[PicParsetId].seq_parameter_set_id].Valid != TRUE)
printf ("PicParset %d references an invalid (uninitialized) Sequence Parameter Set with ID %d, expect the unexpected...\n", PicParsetId, PicParSet[PicParsetId].seq_parameter_set_id);
sps = &SeqParSet[PicParSet[PicParsetId].seq_parameter_set_id];
active_sps = sps;
active_pps = pps;
// In theory, and with a well-designed software, the lines above
// are everything necessary. In practice, we need to patch many values
// in img-> (but no more in inp-> -- these have been taken care of)
// Sequence Parameter Set Stuff first
// printf ("Using Picture Parameter set %d and associated Sequence Parameter Set %d\n", PicParsetId, PicParSet[PicParsetId].seq_parameter_set_id);
// img->log2_max_frame_num_minus4 = sps->log2_max_frame_num_minus4;
img->MaxFrameNum = 1<<(sps->log2_max_frame_num_minus4+4);
img->pic_order_cnt_type = sps->pic_order_cnt_type;
// POC200301
if (img->pic_order_cnt_type < 0 || img->pic_order_cnt_type > 2) // != 1
{
printf ("sps->pic_order_cnt_type %d, expected 1, expect the unexpected...\n", sps->pic_order_cnt_type);
assert (sps->pic_order_cnt_type == 1);
error ("pic_order_cnt_type != 1", -1000);
}
if (img->pic_order_cnt_type == 0)
{
// img->log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_pic_order_cnt_lsb_minus4;
}
else if (img->pic_order_cnt_type == 1) // POC200301
{
img->num_ref_frames_in_pic_order_cnt_cycle = sps->num_ref_frames_in_pic_order_cnt_cycle;
if(img->num_ref_frames_in_pic_order_cnt_cycle != 1)
error("num_ref_frames_in_pic_order_cnt_cycle != 1",-1001);
if(img->num_ref_frames_in_pic_order_cnt_cycle >= MAXnum_ref_frames_in_pic_order_cnt_cycle)
error("num_ref_frames_in_pic_order_cnt_cycle too large",-1011);
img->delta_pic_order_always_zero_flag = sps->delta_pic_order_always_zero_flag;
// if(img->delta_pic_order_always_zero_flag != 0) !KS2
// error ("delta_pic_order_always_zero_flag != 0",-1002);
img->offset_for_non_ref_pic = sps->offset_for_non_ref_pic;
img->offset_for_top_to_bottom_field = sps->offset_for_top_to_bottom_field;
ExpectedDeltaPerPicOrderCntCycle=0;
if (sps->num_ref_frames_in_pic_order_cnt_cycle)
for(i=0;i<(int)sps->num_ref_frames_in_pic_order_cnt_cycle;i++)
{
img->offset_for_ref_frame[i] = sps->offset_for_ref_frame[i];
ExpectedDeltaPerPicOrderCntCycle += sps->offset_for_ref_frame[i];
}
}
img->PicWidthInMbs = (active_sps->pic_width_in_mbs_minus1 +1);
img->PicHeightInMapUnits = (active_sps->pic_height_in_map_units_minus1 +1);
img->FrameHeightInMbs = ( 2 - active_sps->frame_mbs_only_flag ) * img->PicHeightInMapUnits;
img->width = img->PicWidthInMbs * MB_BLOCK_SIZE;
img->width_cr = img->width /2;
img->height = img->FrameHeightInMbs * MB_BLOCK_SIZE;
img->height_cr = img->height / 2;
// Picture Parameter Stuff
img->weighted_pred_flag = pps->weighted_pred_flag;
img->weighted_bipred_idc = pps->weighted_bipred_idc;
img->pic_order_present_flag = pps->pic_order_present_flag;
// POC200301 DELETE
// if(img->pic_order_present_flag != 0)
// error ("pic_order_present_flag != 0",-1004);
img->constrained_intra_pred_flag = pps->constrained_intra_pred_flag;
// currSlice->dp_mode is set by read_new_slice (NALU first byte available there)
if (pps->entropy_coding_mode_flag == UVLC)
{
nal_startcode_follows = uvlc_startcode_follows;
for (i=0; i<3; i++)
{
img->currentSlice->partArr[i].readSyntaxElement = readSyntaxElement_UVLC;
}
}
else
{
nal_startcode_follows = cabac_startcode_follows;
for (i=0; i<3; i++)
{
img->currentSlice->partArr[i].readSyntaxElement = readSyntaxElement_CABAC;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -