
/*!
**************************************************************************************
* \file
*    parset.h
* \brief
*    Picture and Sequence Parameter Sets, encoder operations
*
* \date 25 November 2002
* \author
*    Main contributors (see contributors.h for copyright, address and affiliation details)
*      - Stephan Wenger        <stewe@cs.tu-berlin.de>
***************************************************************************************
*/


#ifndef _PARSET_H_
#define _PARSET_H_

#include "parsetcommon.h"
#include "nalu.h"
#include "sei.h"

extern void GenerateParameterSets (VideoParameters *p_Vid);
extern void FreeParameterSets     (VideoParameters *p_Vid);

extern NALU_t *GenerateSeq_parameter_set_NALU (VideoParameters *p_Vid);
extern NALU_t *GeneratePic_parameter_set_NALU (VideoParameters *p_Vid, int);
extern NALU_t *GenerateSEImessage_NALU(InputParameters *p_Inp);
#if MVC_EXTENSION_ENABLE||NOKIA_USTC_3DV
#if NOKIA_HLS_ADOPTION_M24892
extern int ViewCompOrder(VideoParameters *p_Vid, int depthFlag, int VOIdx);
#endif
extern NALU_t *GenerateSubsetSeq_parameter_set_NALU (VideoParameters *p_Vid);
#if (DEPTH_PARAMETER_SET)
extern NALU_t *GenerateDep_parameter_set_NALU (VideoParameters *p_Vid);
#endif
#endif

// The following are local helpers, but may come handy in the future, hence public
extern void GenerateSequenceParameterSet(seq_parameter_set_rbsp_t *sps, VideoParameters *p_Vid, int SPS_id);
extern void GeneratePictureParameterSet( pic_parameter_set_rbsp_t *pps, seq_parameter_set_rbsp_t *sps, 
										VideoParameters *p_Vid,
										InputParameters *p_Inp, int PPS_id,
										int WeightedPrediction, int WeightedBiprediction,
										int cb_qp_index_offset, int cr_qp_index_offset);
#if (DEPTH_PARAMETER_SET)
extern void GenerateDepthParameterSet(depth_parameter_set_rbsp_t *dps, VideoParameters *p_Vid, int DPS_id);
extern void copy_3dv_acquisition_info(ThreeDVAcquisitionInfo* dst_3dv_acquisition,ThreeDVAcquisitionInfo* src_3dv_acquisition);
#endif

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

#if MVC_EXTENSION_ENABLE||NOKIA_USTC_3DV
extern int  GenerateSeq_parameter_set_rbsp (VideoParameters *p_Vid, seq_parameter_set_rbsp_t *sps, byte *buf, short Is_Subset);
#if (DEPTH_PARAMETER_SET)
extern int  GenerateDep_parameter_set_rbsp (VideoParameters *p_Vid, depth_parameter_set_rbsp_t *dps, byte *buf);
#endif
#else
extern int  GenerateSeq_parameter_set_rbsp (VideoParameters *p_Vid, seq_parameter_set_rbsp_t *sps, byte *buf);
#endif// #if MVC_EXTENSION_ENABLE

#if NOKIA_USTC_3DV
#if DEPTH_PARAMETER_SET
extern void prepare_3dv_acquisition_element_info(VideoParameters* p_TextVid,VideoParameters* p_DepthVid);
extern void cal_3dv_acquisition_element_info(VideoParameters* p_TextVid,VideoParameters* p_DepthVid, int in_subsps);
extern void PrepareAcquisitionElement(VideoParameters* p_TextVid,VideoParameters* p_DepthVid, ThreeDVAE* curr_3dv_ae, ThreeDVAE* sps_3dv_ae, ThreeDVAE* forward_3dv_ae, ThreeDVAE* backward_3dv_ae, int in_subsps);
extern void set_cam_info_for_current_AU(VideoParameters*p_TextVid,VideoParameters* p_DepthVid);
extern int encode_3dv_acquisition_info(ThreeDVAcquisitionInfo* threeDV_acquisition_info, Bitstream* bitstream, int in_subsps, int is_vsp_param_flag);
extern void prepare_3dv_update_info(VideoParameters* p_TextVid,VideoParameters* p_DepthVid, int in_subsps);
#else
extern void prepare_3dv_acquisition_element_info(VideoParameters* p_TextVid,VideoParameters* p_DepthVid);
extern void set_cam_info_for_current_AU(VideoParameters*p_TextVid,VideoParameters* p_DepthVid);
extern int encode_3dv_acquisition_info(ThreeDVUpdateInfo* threeDV_update_info,Bitstream* bitstream,int in_subsps);
extern int generate_3dv_update_info_rbsp(ThreeDVUpdateInfo* threeDV_update_info,byte*buf) ;
extern NALU_t *generate_3dv_update_NALU(VideoParameters* p_DepthVid,ThreeDVUpdateInfo* threeDV_update_info);
#endif
#endif

extern int  GeneratePic_parameter_set_rbsp (VideoParameters *p_Vid, pic_parameter_set_rbsp_t *pps, byte *buf);
extern int  GenerateSEImessage_rbsp (InputParameters *p_Inp, int id, byte *buf);
extern void FreeSPS (seq_parameter_set_rbsp_t *sps);
extern void FreePPS (pic_parameter_set_rbsp_t *pps);
#if (DEPTH_PARAMETER_SET)
extern void FreeDPS (depth_parameter_set_rbsp_t *dps);
#endif

extern int  WriteHRDParameters(seq_parameter_set_rbsp_t *sps, Bitstream *bitstream);
extern void GenerateVUIParameters(seq_parameter_set_rbsp_t *sps, InputParameters *p_Inp);

extern pic_parameter_set_rbsp_t *AllocPPS (void);
extern seq_parameter_set_rbsp_t *AllocSPS (void);
#if (DEPTH_PARAMETER_SET)
extern depth_parameter_set_rbsp_t *AllocDPS (void);
#endif

#endif
