1 #ifndef __H264PARSE_H_
2 #define __H264PARSE_H_
3
4 #include "h264.h"
5
6 #ifndef MFD_FIRMWARE
7 #define true 1
8 #define false 0
9 #endif
10
11 ////////////////////////////////////////////////////////////////////
12 // The following part is only for Parser Debug
13 ///////////////////////////////////////////////////////////////////
14
15
16
17 enum h264_debug_point_id
18 {
19 WARNING_H264_GENERAL = 0xff000000,
20 WARNING_H264_DPB,
21 WARNING_H264_REFLIST,
22 WARNING_H264_SPS,
23 WARNING_H264_PPS,
24 WARNING_H264_SEI,
25 WARNING_H264_VCL,
26
27 ERROR_H264_GENERAL = 0xffff0000,
28 ERROR_H264_DPB,
29 ERROR_H264_REFLIST,
30 ERROR_H264_SPS,
31 ERROR_H264_PPS,
32 ERROR_H264_SEI,
33 ERROR_H264_VCL
34 };
35
MFD_PARSER_DEBUG(int debug_point_id)36 static inline void MFD_PARSER_DEBUG(int debug_point_id)
37 {
38 #ifdef H264_MFD_DEBUG
39
40 int p1,p2,p3,p4,p5,p6;
41
42 p1 = 0x0BAD;
43 p2 = 0xC0DE;
44 p3 = debug_point_id;
45 p4=p5=p6 = 0;
46
47 DEBUG_WRITE(p1,p2,p3,p4,p5,p6);
48 #endif
49
50 debug_point_id = debug_point_id;
51
52 return;
53 }
54
55
56
57
58 ////////////////////////////////////////////////////////////////////
59 ///////////////////////////// Init functions
60 ////////////////////////////////////////////////////////////////////
61 extern void h264_init_old_slice(h264_Info* pInfo);
62 extern void h264_init_img(h264_Info* pInfo);
63 extern void h264_init_Info(h264_Info* pInfo);
64 extern void h264_init_Info_under_sps_pps_level(h264_Info* pInfo);
65 extern void h264_init_sps_pps(struct h264_viddec_parser* parser, uint32_t *persist_mem);
66
67 extern void h264_update_old_slice(h264_Info * pInfo,h264_Slice_Header_t next_SliceHeader);
68 extern void h264_sei_stream_initialise (h264_Info* pInfo);
69 extern void h264_update_img_info(h264_Info * pInfo );
70 extern void h264_update_frame_type(h264_Info * pInfo );
71
72 extern int32_t h264_check_previous_frame_end(h264_Info * pInfo);
73
74
75 ////////////////////////////////////////////////////////////////////
76 ///////////////////////////// bsd functions
77 ////////////////////////////////////////////////////////////////////
78 extern uint8_t h264_More_RBSP_Data(void *parent, h264_Info * pInfo);
79 ////// VLE and bit operation
80 extern uint32_t h264_get_codeNum(void *parent,h264_Info* pInfo);
81 extern int32_t h264_GetVLCElement(void *parent,h264_Info* pInfo, uint8_t bIsSigned);
82
83
84
85 ////////////////////////////////////////////////////////////////////
86 ///////////////////////////// parse functions
87 ////////////////////////////////////////////////////////////////////
88
89 //NAL
90 extern h264_Status h264_Parse_NAL_Unit(void *parent, h264_Info* pInfo, uint8_t *nal_ref_idc);
91
92 ////// Slice header
93 extern h264_Status h264_Parse_Slice_Layer_Without_Partitioning_RBSP(void *parent, h264_Info* pInfo, h264_Slice_Header_t *SliceHeader);
94 extern h264_Status h264_Parse_Slice_Header_1(void *parent, h264_Info* pInfo, h264_Slice_Header_t *SliceHeader);
95 extern h264_Status h264_Parse_Slice_Header_2(void *parent, h264_Info* pInfo, h264_Slice_Header_t *SliceHeader);
96 extern h264_Status h264_Parse_Slice_Header_3(void *parent, h264_Info* pInfo, h264_Slice_Header_t *SliceHeader);
97
98
99 ////// SPS
100 extern h264_Status h264_Parse_SeqParameterSet(void *parent, h264_Info * pInfo,seq_param_set_used_ptr SPS, vui_seq_parameters_t_not_used_ptr pVUI_Seq_Not_Used, int32_t* pOffset_ref_frame);
101 //extern h264_Status h264_Parse_SeqParameterSet_Extension(void *parent, h264_Info * pInfo);
102 extern h264_Status h264_Parse_PicParameterSet(void *parent, h264_Info * pInfo,h264_PicParameterSet_t* PictureParameterSet);
103
104 ////// SEI functions
105 h264_Status h264_Parse_Supplemental_Enhancement_Information_Message(void *parent,h264_Info* pInfo);
106 h264_Status h264_SEI_payload(void *parent, h264_Info* pInfo, h264_sei_payloadtype payloadType, int32_t payloadSize);
107
108 //////
109 extern h264_Status h264_Scaling_List(void *parent, uint8_t *scalingList, int32_t sizeOfScalingList, uint8_t *UseDefaultScalingMatrix, h264_Info* pInfo);
110 extern h264_Status h264_Parse_Ref_Pic_List_Reordering(void *parent,h264_Info* pInfo,h264_Slice_Header_t *SliceHeader);
111 extern h264_Status h264_Parse_Pred_Weight_Table(void *parent,h264_Info* pInfo,h264_Slice_Header_t *SliceHeader);
112 extern h264_Status h264_Parse_Dec_Ref_Pic_Marking(void *parent,h264_Info* pInfo,h264_Slice_Header_t *SliceHeader);
113
114
115
116 ////////////////////////////////////////////////////////////////////
117 ///////////////////////////// utils functions
118 ////////////////////////////////////////////////////////////////////
119 extern int32_t h264_is_new_picture_start(h264_Info* pInfo, h264_Slice_Header_t cur_slice, h264_Slice_Header_t old_slice);
120 extern int32_t h264_is_second_field(h264_Info * pInfo);
121 ///// Math functions
122 uint32_t ldiv_mod_u(uint32_t a, uint32_t b, uint32_t * mod);
123 uint32_t mult_u(uint32_t var1, uint32_t var2);
124 ///// Mem functions
125 extern void* h264_memset( void* buf, uint32_t c, uint32_t num );
126 extern void* h264_memcpy( void* dest, void* src, uint32_t num );
127
128 extern void h264_Parse_Copy_Sps_To_DDR(h264_Info* pInfo, seq_param_set_used_ptr SPS, uint32_t nSPSId);
129 extern void h264_Parse_Copy_Sps_From_DDR(h264_Info* pInfo, seq_param_set_used_ptr SPS, uint32_t nSPSId);
130
131 extern void h264_Parse_Copy_Pps_To_DDR(h264_Info* pInfo, pic_param_set_ptr PPS, uint32_t nPPSId);
132 extern void h264_Parse_Copy_Pps_From_DDR(h264_Info* pInfo, pic_param_set_ptr PPS, uint32_t nPPSId);
133
134 extern void h264_Parse_Copy_Offset_Ref_Frames_To_DDR(h264_Info* pInfo, int32_t* pOffset_ref_frames, uint32_t nSPSId);
135 extern void h264_Parse_Copy_Offset_Ref_Frames_From_DDR(h264_Info* pInfo, int32_t* pOffset_ref_frames, uint32_t nSPSId);
136 extern uint32_t h264_Parse_Check_Sps_Updated_Flag(h264_Info* pInfo, uint32_t nSPSId);
137 extern void h264_Parse_Clear_Sps_Updated_Flag(h264_Info* pInfo, uint32_t nSPSId);
138
139
140 ////////////////////////////////////////////////////////////////////
141 ///////////////////////////// workload functions
142 ////////////////////////////////////////////////////////////////////
143
144 extern void h264_parse_emit_current_slice( void *parent, h264_Info *pInfo );
145
146 extern void h264_parse_emit_current_pic( void *parent, h264_Info *pInfo );
147
148 extern void h264_parse_emit_start_new_frame( void *parent, h264_Info *pInfo );
149 extern void h264_parse_emit_eos( void *parent, h264_Info *pInfo );
150
151
152
153 ////////////////////////////////////////////////////////////////////
154 ///////////////////////////// utils functions outside h264
155 ////////////////////////////////////////////////////////////////////
156
157 extern void *memset(void *s, int32_t c, uint32_t n);
158 extern void *memcpy(void *dest, const void *src, uint32_t n);
159 extern uint32_t cp_using_dma(uint32_t ddr_addr, uint32_t local_addr, uint32_t size, char to_ddr, char swap);
160 extern int32_t viddec_pm_get_bits(void *parent, uint32_t *data, uint32_t num_bits);
161 extern int32_t viddec_pm_peek_bits(void *parent, uint32_t *data, uint32_t num_bits);
162
163
164
165 ////////////////////////////////////////////////////////////////////
166 ///////////////////////////// Second level parse functions
167 ////////////////////////////////////////////////////////////////////
168
169 #endif ////__H264PARSE_H_
170
171
172
173