parset.c File Reference

Picture and Sequence Parameter set generation and handling. More...

#include <time.h>
#include <sys/timeb.h>
#include <limits.h>
#include "global.h"
#include "contributors.h"
#include "nal.h"
#include "mbuffer.h"
#include "parset.h"
#include "vlc.h"
#include "q_matrix.h"

Include dependency graph for parset.c:

Go to the source code of this file.

Functions

static int IdentifyProfile (void)
static int IdentifyLevel (void)
static int GenerateVUI_parameters_rbsp (seq_parameter_set_rbsp_t *sps, Bitstream *bitstream)
void GenerateParameterSets (void)
void FreeParameterSets (void)
NALU_t * GenerateSeq_parameter_set_NALU (void)
NALU_t * GeneratePic_parameter_set_NALU (int PPS_id)
void GenerateSequenceParameterSet (seq_parameter_set_rbsp_t *sps, int SPS_id)
void GeneratePictureParameterSet (pic_parameter_set_rbsp_t *pps, seq_parameter_set_rbsp_t *sps, int PPS_id, int WeightedPrediction, int WeightedBiprediction, int cb_qp_index_offset, int cr_qp_index_offset)
int Scaling_List (short *scalingListinput, short *scalingList, int sizeOfScalingList, short *UseDefaultScalingMatrix, Bitstream *bitstream)
int GenerateSeq_parameter_set_rbsp (seq_parameter_set_rbsp_t *sps, byte *rbsp)
int GeneratePic_parameter_set_rbsp (pic_parameter_set_rbsp_t *pps, byte *rbsp)
NALU_t * GenerateSEImessage_NALU ()
int GenerateSEImessage_rbsp (int id, byte *rbsp)
int WriteHRDParameters (seq_parameter_set_rbsp_t *sps, Bitstream *bitstream)
void GenerateVUIParameters (seq_parameter_set_rbsp_t *sps)

Variables

ColocatedParams * Co_located
ColocatedParams * Co_located_JV [MAX_PLANE]
pic_parameter_set_rbsp_t * PicParSet [MAXPPS]
static const byte ZZ_SCAN [16]
static const byte ZZ_SCAN8 [64]


Detailed Description

Picture and Sequence Parameter set generation and handling.

parset.c

Date:
25 November 2002
Author:
Main contributors (see contributors.h for copyright, address and affiliation details)

Definition in file parset.c.


Function Documentation

void FreeParameterSets ( void   ) 

frees global parameter sets active_sps and active_pps

Returns:
A NALU containing the Sequence ParameterSet

Definition at line 121 of file parset.c.

References FreePPS(), and FreeSPS().

Referenced by free_encoder_memory().

Here is the call graph for this function:

void GenerateParameterSets ( void   ) 

generates a sequence and picture parameter set and stores these in global active_sps and active_pps

Returns:
A NALU containing the Sequence ParameterSet

Definition at line 62 of file parset.c.

References AllocPPS(), AllocSPS(), InputParameters::cb_qp_index_offset, InputParameters::chroma_qp_index_offset, InputParameters::cr_qp_index_offset, InputParameters::GenerateMultiplePPS, GeneratePictureParameterSet(), GenerateSequenceParameterSet(), InputParameters::WeightedBiprediction, and InputParameters::WeightedPrediction.

Referenced by init_encoder().

Here is the call graph for this function:

NALU_t* GeneratePic_parameter_set_NALU ( int  PPS_id  ) 

NALU_t *GeneratePic_parameter_set_NALU (int PPS_id);.

Note:
Uses the global variables through GenerateSequenceParameterSet() and GeneratePictureParameterSet
Returns:
A NALU containing the Picture Parameter Set

Definition at line 180 of file parset.c.

References AllocNALU(), GeneratePic_parameter_set_rbsp(), RBSPtoNALU(), and NALU_t::startcodeprefix_len.

Referenced by write_PPS().

Here is the call graph for this function:

int GeneratePic_parameter_set_rbsp ( pic_parameter_set_rbsp_t *  pps,
byte *  rbsp 
)

int GeneratePic_parameter_set_rbsp (pic_parameter_set_rbsp_t *sps, char *rbsp);

Parameters:
pps picture parameter structure
rbsp buffer to be filled with the rbsp, size should be at least MAXIMUMPARSETRBSPSIZE
Returns:
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)

Definition at line 737 of file parset.c.

References Bitstream::bits_to_go, Bitstream::byte_pos, IdentifyProfile(), no_mem_exit(), ImageParameters::pic_order_present_flag, Scaling_List(), se_v(), SODBtoRBSP(), Bitstream::streamBuffer, u_1(), u_v(), and ue_v().

Referenced by GeneratePic_parameter_set_NALU().

Here is the call graph for this function:

void GeneratePictureParameterSet ( pic_parameter_set_rbsp_t *  pps,
seq_parameter_set_rbsp_t *  sps,
int  PPS_id,
int  WeightedPrediction,
int  WeightedBiprediction,
int  cb_qp_index_offset,
int  cr_qp_index_offset 
)

GeneratePictureParameterSet: Generates a Picture Parameter Set structure.

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.

Following set the parameter for different slice group types

Parameters:
pps  Picture Parameter Set to be filled
sps  used Sequence Parameter Set
PPS_id  PPS ID
WeightedPrediction  value of weighted_pred_flag
WeightedBiprediction  value of weighted_bipred_idc
cb_qp_index_offset  value of cb_qp_index_offset
cr_qp_index_offset  value of cr_qp_index_offset

Definition at line 398 of file parset.c.

References ImageParameters::auto_crop_bottom, ImageParameters::auto_crop_right, InputParameters::bottom_right, InputParameters::DFSendParameters, FREXT_CAVLC444, FREXT_Hi10P, FREXT_Hi422, FREXT_Hi444, FREXT_HP, IdentifyProfile(), no_mem_exit(), InputParameters::num_slice_groups_minus1, InputParameters::output, ImageParameters::pic_order_present_flag, InputParameters::redundant_pic_flag, InputParameters::run_length_minus1, InputParameters::ScalingListPresentFlag, InputParameters::ScalingMatrixPresentFlag, InputParameters::slice_group_change_direction_flag, InputParameters::slice_group_change_rate_minus1, InputParameters::slice_group_id, InputParameters::slice_group_map_type, InputParameters::symbol_mode, InputParameters::top_left, InputParameters::Transform8x8Mode, InputParameters::UseConstrainedIntraPred, and YUV444.

Referenced by GenerateParameterSets().

Here is the call graph for this function:

NALU_t* GenerateSEImessage_NALU (  ) 

Function body for SEI message NALU generation.

Returns:
A NALU containing the SEI messages

Definition at line 1002 of file parset.c.

References AllocNALU(), GenerateSEImessage_rbsp(), RBSPtoNALU(), and NALU_t::startcodeprefix_len.

Referenced by rewrite_paramsets(), and start_sequence().

Here is the call graph for this function:

int GenerateSEImessage_rbsp ( int  id,
byte *  rbsp 
)

int GenerateSEImessage_rbsp (int, bufferingperiod_information_struct*, char*)

Returns:
size of the RBSP in bytes, negative in case of an error
Note:

Definition at line 1029 of file parset.c.

References Bitstream::bits_to_go, Bitstream::byte_pos, no_mem_exit(), sei_message, InputParameters::SEIMessageText, SODBtoRBSP(), Bitstream::streamBuffer, and u_v().

Referenced by GenerateSEImessage_NALU().

Here is the call graph for this function:

NALU_t* GenerateSeq_parameter_set_NALU ( void   ) 

int GenerateSeq_parameter_set_NALU (void);

Note:
Uses the global variables through GenerateSequenceParameterSet() and GeneratePictureParameterSet
Returns:
A NALU containing the Sequence ParameterSet

Definition at line 150 of file parset.c.

References AllocNALU(), GenerateSeq_parameter_set_rbsp(), RBSPtoNALU(), and NALU_t::startcodeprefix_len.

Referenced by rewrite_paramsets(), and start_sequence().

Here is the call graph for this function:

int GenerateSeq_parameter_set_rbsp ( seq_parameter_set_rbsp_t *  sps,
byte *  rbsp 
)

int GenerateSeq_parameter_set_rbsp (seq_parameter_set_rbsp_t *sps, char *rbsp);

Parameters:
sps sequence parameter structure
rbsp buffer to be filled with the rbsp, size should be at least MAXIMUMPARSETRBSPSIZE
Returns:
size of the RBSP in bytes
Note:
Sequence Parameter VUI function is called, but the function implements an exit (-1)

Definition at line 612 of file parset.c.

References Bitstream::bits_to_go, Bitstream::byte_pos, GenerateVUI_parameters_rbsp(), ImageParameters::lossless_qpprime_flag, no_mem_exit(), Scaling_List(), se_v(), SODBtoRBSP(), Bitstream::streamBuffer, u_1(), u_v(), ue_v(), YUV444, and ImageParameters::yuv_format.

Referenced by GenerateSeq_parameter_set_NALU().

Here is the call graph for this function:

void GenerateSequenceParameterSet ( seq_parameter_set_rbsp_t *  sps,
int  SPS_id 
)

GenerateSequenceParameterSet: extracts info from global variables and generates sequence parameter set structure.

Function reads all kinds of values from several global variables, including params-> and image-> and fills in the sps. Many values are current hard-coded to defaults.

POC stuff: The following values are hard-coded in init_poc(). Apparently, the poc implementation covers only a subset of the poc functionality. Here, the same subset is implemented. Changes in the POC stuff have also to be reflected here

Parameters:
sps  Sequence Parameter Set to be filled
SPS_id  SPS ID

Definition at line 209 of file parset.c.

References alloc_colocated(), ImageParameters::auto_crop_bottom, ImageParameters::auto_crop_right, ImageParameters::delta_pic_order_always_zero_flag, InputParameters::directInferenceFlag, InputParameters::EnableVUISupport, error(), FREXT_CAVLC444, FREXT_Hi10P, FREXT_Hi422, FREXT_Hi444, FREXT_HP, GenerateVUIParameters(), IdentifyLevel(), IdentifyProfile(), InputParameters::IntraProfile, ImageParameters::lossless_qpprime_flag, InputParameters::LosslessCoding, InputParameters::MbInterlace, InputParameters::num_ref_frames, ImageParameters::num_ref_frames_in_pic_order_cnt_cycle, ImageParameters::offset_for_non_ref_pic, ImageParameters::offset_for_ref_frame, ImageParameters::offset_for_top_to_bottom_field, InputParameters::output, InputParameters::pic_order_cnt_type, InputParameters::PicInterlace, InputParameters::rgb_input_flag, InputParameters::ScalingListPresentFlag, InputParameters::ScalingMatrixPresentFlag, InputParameters::separate_colour_plane_flag, InputParameters::Transform8x8Mode, and YUV444.

Referenced by GenerateParameterSets().

Here is the call graph for this function:

static int GenerateVUI_parameters_rbsp ( seq_parameter_set_rbsp_t *  sps,
Bitstream *  bitstream 
) [static]

Function body for VUI Parameter generation (to be done).

Returns:
exits with error message

Definition at line 907 of file parset.c.

References u_1(), u_v(), ue_v(), and WriteHRDParameters().

Referenced by GenerateSeq_parameter_set_rbsp().

Here is the call graph for this function:

void GenerateVUIParameters ( seq_parameter_set_rbsp_t *  sps  ) 

int IdentifyLevel ( void   )  [static]

Returns the Level.

Returns:
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)

Definition at line 892 of file parset.c.

References InputParameters::LevelIDC.

Referenced by GenerateSequenceParameterSet().

int IdentifyProfile ( void   )  [static]

Returns the Profile.

Returns:
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;

Definition at line 874 of file parset.c.

References InputParameters::ProfileIDC.

Referenced by GeneratePic_parameter_set_rbsp(), GeneratePictureParameterSet(), and GenerateSequenceParameterSet().

int Scaling_List ( short *  scalingListinput,
short *  scalingList,
int  sizeOfScalingList,
short *  UseDefaultScalingMatrix,
Bitstream *  bitstream 
)

syntax for scaling list matrix values

Parameters:
scalingListinput input scaling list
scalingList scaling list to be used
sizeOfScalingList size of the scaling list
UseDefaultScalingMatrix usage of default Scaling Matrix
bitstream target bitstream for writing syntax
Returns:
size of the RBSP in bytes

Definition at line 560 of file parset.c.

References se_v().

Referenced by GeneratePic_parameter_set_rbsp(), and GenerateSeq_parameter_set_rbsp().

Here is the call graph for this function:

int WriteHRDParameters ( seq_parameter_set_rbsp_t *  sps,
Bitstream *  bitstream 
)

int WriteHRDParameters((seq_parameter_set_rbsp_t *sps, Bitstream *bitstream)

Returns:
size of the RBSP in bytes, negative in case of an error
Note:

Definition at line 1098 of file parset.c.

References u_1(), u_v(), and ue_v().

Referenced by GenerateVUI_parameters_rbsp().

Here is the call graph for this function:


Variable Documentation

Co_located to be used during 4:4:4 independent mode encoding.

Definition at line 42 of file mbuffer.c.

const byte ZZ_SCAN[16] [static]

Initial value:

{  0,  1,  4,  8,  5,  2,  3,  6,  9, 12, 13, 10,  7, 11, 14, 15
}

Definition at line 39 of file parset.c.

const byte ZZ_SCAN8[64] [static]

Initial value:

{  0,  1,  8, 16,  9,  2,  3, 10, 17, 24, 32, 25, 18, 11,  4,  5,
   12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13,  6,  7, 14, 21, 28,
   35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51,
   58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63
}

Definition at line 43 of file parset.c.


Documentation generated with DoxyGen