Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__H264__App
view libavcodec/avcodec.h @ 2:897f711a7157
rearrange to work with autoconf
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Tue, 25 Sep 2012 15:55:33 +0200 |
| parents | |
| children |
line source
1 #ifndef AVCODEC_AVCODEC_H
2 #define AVCODEC_AVCODEC_H
4 #include <errno.h>
5 #include <stdint.h>
6 #include "config.h"
8 #include "libavutil/mem.h"
10 #define MAX_SPS_COUNT 32
11 #define MAX_PPS_COUNT 256
14 #ifndef CABAC
15 #define CABAC h->pps.cabac
16 #endif
18 #define EXTENDED_SAR 255
20 #define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16 bit
21 #define MB_TYPE_8x8DCT 0x01000000
22 #define IS_REF0(a) ((a) & MB_TYPE_REF0)
23 #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
25 #define LIST_NOT_USED -1
26 #define PART_NOT_AVAILABLE -2
28 /* dct code */
29 typedef short DCTELEM;
31 /**
32 * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
33 * This is mainly needed because some optimized bitstream readers read
34 * 32 or 64 bit at once and could read over the end.<br>
35 * Note: If the first 23 bits of the additional bytes are not 0, then damaged
36 * MPEG bitstreams could cause overread and segfault.
37 */
38 #define FF_INPUT_BUFFER_PADDING_SIZE 8
40 enum AVColorPrimaries{
41 AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
42 AVCOL_PRI_UNSPECIFIED=2,
43 AVCOL_PRI_BT470M =4,
44 AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
45 AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
46 AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above
47 AVCOL_PRI_FILM =8,
48 AVCOL_PRI_NB , ///< Not part of ABI
49 };
51 enum AVColorTransferCharacteristic{
52 AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361
53 AVCOL_TRC_UNSPECIFIED=2,
54 AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
55 AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG
56 AVCOL_TRC_NB , ///< Not part of ABI
57 };
59 enum AVColorSpace{
60 AVCOL_SPC_RGB =0,
61 AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
62 AVCOL_SPC_UNSPECIFIED=2,
63 AVCOL_SPC_FCC =4,
64 AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
65 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
66 AVCOL_SPC_SMPTE240M =7,
67 AVCOL_SPC_NB , ///< Not part of ABI
68 };
70 enum AVColorRange{
71 AVCOL_RANGE_UNSPECIFIED=0,
72 AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges
73 AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges
74 AVCOL_RANGE_NB , ///< Not part of ABI
75 };
77 #define MAX_MMCO_COUNT 66
78 /**
79 * Memory management control operation opcode.
80 */
81 typedef enum MMCOOpcode{
82 MMCO_END=0,
83 MMCO_SHORT2UNUSED,
84 MMCO_LONG2UNUSED,
85 MMCO_SHORT2LONG,
86 MMCO_SET_MAX_LONG,
87 MMCO_RESET,
88 MMCO_LONG,
89 } MMCOOpcode;
91 /* NAL unit types */
92 enum {
93 NAL_SLICE=1,
94 NAL_DPA,
95 NAL_DPB,
96 NAL_DPC,
97 NAL_IDR_SLICE,
98 NAL_SEI,
99 NAL_SPS,
100 NAL_PPS,
101 NAL_AUD,
102 NAL_END_SEQUENCE,
103 NAL_END_STREAM,
104 NAL_FILLER_DATA,
105 NAL_SPS_EXT,
106 NAL_AUXILIARY_SLICE=19
107 };
109 /**
110 * SEI message types
111 */
112 typedef enum {
113 SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1)
114 SEI_TYPE_PIC_TIMING = 1, ///< picture timing
115 SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data
116 SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync)
117 } SEI_Type;
119 /**
120 * pic_struct in picture timing SEI message
121 */
122 typedef enum {
123 SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame
124 SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field
125 SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field
126 SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order
127 SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order
128 SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order
129 SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order
130 SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling
131 SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling
132 } SEI_PicStructType;
134 #define FF_MAX_B_FRAMES 16
137 //The following defines may change, don't expect compatibility if you use them.
138 #define MB_TYPE_INTRA4x4 0x0001
139 #define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific
140 #define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific
141 #define MB_TYPE_16x16 0x0008
142 #define MB_TYPE_16x8 0x0010
143 #define MB_TYPE_8x16 0x0020
144 #define MB_TYPE_8x8 0x0040
145 #define MB_TYPE_INTERLACED 0x0080
146 #define MB_TYPE_DIRECT2 0x0100 //FIXME
147 #define MB_TYPE_ACPRED 0x0200
148 #define MB_TYPE_GMC 0x0400
149 #define MB_TYPE_SKIP 0x0800
150 #define MB_TYPE_P0L0 0x1000
151 #define MB_TYPE_P1L0 0x2000
152 #define MB_TYPE_P0L1 0x4000
153 #define MB_TYPE_P1L1 0x8000
154 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
155 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
156 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
157 #define MB_TYPE_QUANT 0x00010000
158 #define MB_TYPE_CBP 0x00020000
159 //Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...)
161 #define FF_BUFFER_TYPE_INTERNAL 1
162 #define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user)
163 #define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared.
164 #define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything.
167 #define FF_I_TYPE 1 ///< Intra
168 #define FF_P_TYPE 2 ///< Predicted
169 #define FF_B_TYPE 3 ///< Bi-dir predicted
170 #define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4
171 #define FF_SI_TYPE 5 ///< Switching Intra
172 #define FF_SP_TYPE 6 ///< Switching Predicted
173 #define FF_BI_TYPE 7
175 #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type
176 #define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4)
177 #define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16)
178 #define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
179 #define IS_INTRA(a) ((a)&7)
180 #define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8))
181 #define IS_SKIP(a) ((a)&MB_TYPE_SKIP)
182 #define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM)
183 #define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED)
184 #define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2)
185 #define IS_GMC(a) ((a)&MB_TYPE_GMC)
186 #define IS_16X16(a) ((a)&MB_TYPE_16x16)
187 #define IS_16X8(a) ((a)&MB_TYPE_16x8)
188 #define IS_8X16(a) ((a)&MB_TYPE_8x16)
189 #define IS_8X8(a) ((a)&MB_TYPE_8x8)
190 #define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused
191 #define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused
192 #define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused
193 #define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused
194 #define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED)
195 #define IS_QUANT(a) ((a)&MB_TYPE_QUANT)
196 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list))))
197 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note does not work if subMBs
198 #define HAS_CBP(a) ((a)&MB_TYPE_CBP)
201 #define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */
202 /* lower 16 bits - CPU features */
203 #define FF_MM_MMX 0x0001 ///< standard MMX
204 #define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW
205 #define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext
206 #define FF_MM_SSE 0x0008 ///< SSE functions
207 #define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions
208 #define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt
209 #define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions
210 #define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions
211 #define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions
212 #define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions
213 #define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT
214 #define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec
217 /**
218 * Sequence parameter set
219 */
220 typedef struct SPS{
222 int profile_idc;
223 int level_idc;
224 int chroma_format_idc;
225 int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag
226 int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4
227 int poc_type; ///< pic_order_cnt_type
228 int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4
229 int delta_pic_order_always_zero_flag;
230 int offset_for_non_ref_pic;
231 int offset_for_top_to_bottom_field;
232 int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle
233 int ref_frame_count; ///< num_ref_frames
234 int gaps_in_frame_num_allowed_flag;
235 int mb_width; ///< pic_width_in_mbs_minus1 + 1
236 int mb_height; ///< pic_height_in_map_units_minus1 + 1
237 int frame_mbs_only_flag;
238 int mb_aff; ///<mb_adaptive_frame_field_flag
239 int direct_8x8_inference_flag;
240 int crop; ///< frame_cropping_flag
241 unsigned int crop_left; ///< frame_cropping_rect_left_offset
242 unsigned int crop_right; ///< frame_cropping_rect_right_offset
243 unsigned int crop_top; ///< frame_cropping_rect_top_offset
244 unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset
245 int vui_parameters_present_flag;
246 int num,den;
248 int video_signal_type_present_flag;
249 int full_range;
250 int colour_description_present_flag;
251 enum AVColorPrimaries color_primaries;
252 enum AVColorTransferCharacteristic color_trc;
253 enum AVColorSpace colorspace;
254 int timing_info_present_flag;
255 uint32_t num_units_in_tick;
256 uint32_t time_scale;
257 int fixed_frame_rate_flag;
258 short offset_for_ref_frame[256]; //FIXME dyn aloc?
259 int bitstream_restriction_flag;
260 int num_reorder_frames;
261 int scaling_matrix_present;
262 uint8_t scaling_matrix4[6][16];
263 uint8_t scaling_matrix8[2][64];
264 int nal_hrd_parameters_present_flag;
265 int vcl_hrd_parameters_present_flag;
266 int pic_struct_present_flag;
267 int time_offset_length;
268 int cpb_cnt; ///< See H.264 E.1.2
269 int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 +1
270 int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1
271 int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1
272 int bit_depth_luma; ///< bit_depth_luma_minus8 + 8
273 int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8
274 int residual_color_transform_flag; ///< residual_colour_transform_flag
275 }SPS;
277 /**
278 * Picture parameter set
279 */
280 typedef struct PPS{
281 unsigned int sps_id;
282 int cabac; ///< entropy_coding_mode_flag
283 int pic_order_present; ///< pic_order_present_flag
284 int slice_group_count; ///< num_slice_groups_minus1 + 1
285 int mb_slice_group_map_type;
286 unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
287 int weighted_pred; ///< weighted_pred_flag
288 int weighted_bipred_idc;
289 int init_qp; ///< pic_init_qp_minus26 + 26
290 int init_qs; ///< pic_init_qs_minus26 + 26
291 int chroma_qp_index_offset[2];
292 int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag
293 int constrained_intra_pred; ///< constrained_intra_pred_flag
294 int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag
295 int transform_8x8_mode; ///< transform_8x8_mode_flag
296 uint8_t scaling_matrix4[6][16];
297 uint8_t scaling_matrix8[2][64];
298 uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table
299 int chroma_qp_diff;
300 }PPS;
302 typedef struct TopBorder{
303 uint8_t unfiltered_y[16];
304 uint8_t unfiltered_cb[8];
305 uint8_t unfiltered_cr[8];
307 uint8_t top_borders_y[16*4];
308 uint8_t top_borders_cb[8*2];
309 uint8_t top_borders_cr[8*2];
310 }TopBorder;
312 typedef struct LeftBorder{
313 uint8_t unfiltered_y[17];
314 uint8_t unfiltered_cb[9];
315 uint8_t unfiltered_cr[9];
316 }LeftBorder;
318 typedef struct H264Mb {
319 //variables copied in after cabac decoding
320 int16_t mb_x, mb_y;
321 int32_t mb_type;
323 uint16_t cbp; // coded block pattern, idct, deblock
324 int8_t qscale_mb_xy; // qp, deblock
325 int8_t qscale_left_mb_xy; //not required
326 int8_t qscale_top_mb_xy;
328 DECLARE_ALIGNED(8, uint16_t, sub_mb_type[4]);
329 DECLARE_ALIGNED(8, uint8_t, non_zero_count[24]); //idct deblock
330 DECLARE_ALIGNED(16, int16_t, mb[16*24]); //coeffs, idct
332 union{
333 struct {
334 DECLARE_ALIGNED(8, int8_t, ref_index[2][4]); //mc, deblock
335 DECLARE_ALIGNED(16, int16_t, mvd[2][16][2]); //mc, deblock
336 };
337 struct {
338 DECLARE_ALIGNED(8, int8_t, intra4x4_pred_mode[16]); //intra, deblock
339 int8_t chroma_pred_mode; //intra
340 int8_t intra16x16_pred_mode; //intra, deblock
341 };
342 };
344 #if OMPSS
345 DECLARE_ALIGNED(8, uint8_t, top_border[16+ 2*8]);
346 DECLARE_ALIGNED(8, uint8_t, top_border_next[8]);
347 DECLARE_ALIGNED(8, uint8_t, left_border[17+2*9]);
348 int8_t intra4x4_pred_mode_left[4];
349 #endif
351 } H264Mb;
353 typedef struct RawFrame {
354 uint8_t *data;
355 int size;
356 unsigned int data_size;
357 int64_t pos; ///< byte position in stream, -1 if unknown
358 int state;
359 } RawFrame;
361 typedef struct PictureInfo{
362 int ref_poc[2][16]; ///< h264 POCs of the frames used as reference
363 int ref_count[2]; ///< number of entries in ref_poc
364 int poc; ///< h264 frame POC
365 int frame_num; ///< h264 frame_num (raw frame_num from slice header)
366 int pic_id;
367 int long_ref;
368 int cpn; ///coded picture number
369 int slice_type_nos;
370 // int key_frame;
371 // int mmco_reset; ///< h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET.
373 int reference; //Set to 4 for delayed, non-reference frames. 1-3 for reference. FIXME
375 }PictureInfo;
377 typedef struct DecodedPicture{
378 int16_t (*motion_val[2])[2];
379 int16_t (*motion_val_base[2])[2];
381 /**
382 * motion reference frame index
383 * the order in which these are stored can depend on the codec.
384 * - encoding: Set by user.
385 * - decoding: Set by libavcodec.
386 */
387 int8_t *ref_index[2];
388 uint32_t *mb_type; //mb_type_base + mb_width + 2
389 uint32_t *mb_type_base;
391 int8_t *intra4x4_pred_mode;
392 int8_t *non_zero_count;
394 uint8_t *data[3]; //point to first pixel in the frame
395 int linesize[3];
396 uint8_t *base[3]; //base of picture planes
398 int cpn; /// coded picture number
399 int poc; ///< h264 frame POC
400 int reference; // 0 -> free, 1 -> needs to be displayed, 2 -> needed for reference, 3 -> 1 && 2
401 int key_frame;
402 int mmco_reset; ///< h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET.
404 } DecodedPicture;
407 #endif /* AVCODEC_AVCODEC_H */
