Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__H264__App
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libavcodec/avcodec.h Tue Sep 25 15:55:33 2012 +0200 1.3 @@ -0,0 +1,407 @@ 1.4 +#ifndef AVCODEC_AVCODEC_H 1.5 +#define AVCODEC_AVCODEC_H 1.6 + 1.7 +#include <errno.h> 1.8 +#include <stdint.h> 1.9 +#include "config.h" 1.10 + 1.11 +#include "libavutil/mem.h" 1.12 + 1.13 +#define MAX_SPS_COUNT 32 1.14 +#define MAX_PPS_COUNT 256 1.15 + 1.16 + 1.17 +#ifndef CABAC 1.18 +#define CABAC h->pps.cabac 1.19 +#endif 1.20 + 1.21 +#define EXTENDED_SAR 255 1.22 + 1.23 +#define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16 bit 1.24 +#define MB_TYPE_8x8DCT 0x01000000 1.25 +#define IS_REF0(a) ((a) & MB_TYPE_REF0) 1.26 +#define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) 1.27 + 1.28 +#define LIST_NOT_USED -1 1.29 +#define PART_NOT_AVAILABLE -2 1.30 + 1.31 +/* dct code */ 1.32 +typedef short DCTELEM; 1.33 + 1.34 +/** 1.35 +* Required number of additionally allocated bytes at the end of the input bitstream for decoding. 1.36 +* This is mainly needed because some optimized bitstream readers read 1.37 +* 32 or 64 bit at once and could read over the end.<br> 1.38 +* Note: If the first 23 bits of the additional bytes are not 0, then damaged 1.39 +* MPEG bitstreams could cause overread and segfault. 1.40 +*/ 1.41 +#define FF_INPUT_BUFFER_PADDING_SIZE 8 1.42 + 1.43 +enum AVColorPrimaries{ 1.44 + AVCOL_PRI_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B 1.45 + AVCOL_PRI_UNSPECIFIED=2, 1.46 + AVCOL_PRI_BT470M =4, 1.47 + AVCOL_PRI_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM 1.48 + AVCOL_PRI_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC 1.49 + AVCOL_PRI_SMPTE240M =7, ///< functionally identical to above 1.50 + AVCOL_PRI_FILM =8, 1.51 + AVCOL_PRI_NB , ///< Not part of ABI 1.52 +}; 1.53 + 1.54 +enum AVColorTransferCharacteristic{ 1.55 + AVCOL_TRC_BT709 =1, ///< also ITU-R BT1361 1.56 + AVCOL_TRC_UNSPECIFIED=2, 1.57 + AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM 1.58 + AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG 1.59 + AVCOL_TRC_NB , ///< Not part of ABI 1.60 +}; 1.61 + 1.62 +enum AVColorSpace{ 1.63 + AVCOL_SPC_RGB =0, 1.64 + AVCOL_SPC_BT709 =1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B 1.65 + AVCOL_SPC_UNSPECIFIED=2, 1.66 + AVCOL_SPC_FCC =4, 1.67 + 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 1.68 + AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above 1.69 + AVCOL_SPC_SMPTE240M =7, 1.70 + AVCOL_SPC_NB , ///< Not part of ABI 1.71 +}; 1.72 + 1.73 +enum AVColorRange{ 1.74 + AVCOL_RANGE_UNSPECIFIED=0, 1.75 + AVCOL_RANGE_MPEG =1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges 1.76 + AVCOL_RANGE_JPEG =2, ///< the normal 2^n-1 "JPEG" YUV ranges 1.77 + AVCOL_RANGE_NB , ///< Not part of ABI 1.78 +}; 1.79 + 1.80 +#define MAX_MMCO_COUNT 66 1.81 +/** 1.82 +* Memory management control operation opcode. 1.83 +*/ 1.84 +typedef enum MMCOOpcode{ 1.85 + MMCO_END=0, 1.86 + MMCO_SHORT2UNUSED, 1.87 + MMCO_LONG2UNUSED, 1.88 + MMCO_SHORT2LONG, 1.89 + MMCO_SET_MAX_LONG, 1.90 + MMCO_RESET, 1.91 + MMCO_LONG, 1.92 +} MMCOOpcode; 1.93 + 1.94 +/* NAL unit types */ 1.95 +enum { 1.96 + NAL_SLICE=1, 1.97 + NAL_DPA, 1.98 + NAL_DPB, 1.99 + NAL_DPC, 1.100 + NAL_IDR_SLICE, 1.101 + NAL_SEI, 1.102 + NAL_SPS, 1.103 + NAL_PPS, 1.104 + NAL_AUD, 1.105 + NAL_END_SEQUENCE, 1.106 + NAL_END_STREAM, 1.107 + NAL_FILLER_DATA, 1.108 + NAL_SPS_EXT, 1.109 + NAL_AUXILIARY_SLICE=19 1.110 +}; 1.111 + 1.112 +/** 1.113 +* SEI message types 1.114 +*/ 1.115 +typedef enum { 1.116 + SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) 1.117 + SEI_TYPE_PIC_TIMING = 1, ///< picture timing 1.118 + SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data 1.119 + SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) 1.120 +} SEI_Type; 1.121 + 1.122 +/** 1.123 +* pic_struct in picture timing SEI message 1.124 +*/ 1.125 +typedef enum { 1.126 + SEI_PIC_STRUCT_FRAME = 0, ///< 0: %frame 1.127 + SEI_PIC_STRUCT_TOP_FIELD = 1, ///< 1: top field 1.128 + SEI_PIC_STRUCT_BOTTOM_FIELD = 2, ///< 2: bottom field 1.129 + SEI_PIC_STRUCT_TOP_BOTTOM = 3, ///< 3: top field, bottom field, in that order 1.130 + SEI_PIC_STRUCT_BOTTOM_TOP = 4, ///< 4: bottom field, top field, in that order 1.131 + SEI_PIC_STRUCT_TOP_BOTTOM_TOP = 5, ///< 5: top field, bottom field, top field repeated, in that order 1.132 + SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM = 6, ///< 6: bottom field, top field, bottom field repeated, in that order 1.133 + SEI_PIC_STRUCT_FRAME_DOUBLING = 7, ///< 7: %frame doubling 1.134 + SEI_PIC_STRUCT_FRAME_TRIPLING = 8 ///< 8: %frame tripling 1.135 +} SEI_PicStructType; 1.136 + 1.137 +#define FF_MAX_B_FRAMES 16 1.138 + 1.139 + 1.140 +//The following defines may change, don't expect compatibility if you use them. 1.141 +#define MB_TYPE_INTRA4x4 0x0001 1.142 +#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific 1.143 +#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific 1.144 +#define MB_TYPE_16x16 0x0008 1.145 +#define MB_TYPE_16x8 0x0010 1.146 +#define MB_TYPE_8x16 0x0020 1.147 +#define MB_TYPE_8x8 0x0040 1.148 +#define MB_TYPE_INTERLACED 0x0080 1.149 +#define MB_TYPE_DIRECT2 0x0100 //FIXME 1.150 +#define MB_TYPE_ACPRED 0x0200 1.151 +#define MB_TYPE_GMC 0x0400 1.152 +#define MB_TYPE_SKIP 0x0800 1.153 +#define MB_TYPE_P0L0 0x1000 1.154 +#define MB_TYPE_P1L0 0x2000 1.155 +#define MB_TYPE_P0L1 0x4000 1.156 +#define MB_TYPE_P1L1 0x8000 1.157 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) 1.158 +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) 1.159 +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) 1.160 +#define MB_TYPE_QUANT 0x00010000 1.161 +#define MB_TYPE_CBP 0x00020000 1.162 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) 1.163 + 1.164 +#define FF_BUFFER_TYPE_INTERNAL 1 1.165 +#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) 1.166 +#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. 1.167 +#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. 1.168 + 1.169 + 1.170 +#define FF_I_TYPE 1 ///< Intra 1.171 +#define FF_P_TYPE 2 ///< Predicted 1.172 +#define FF_B_TYPE 3 ///< Bi-dir predicted 1.173 +#define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4 1.174 +#define FF_SI_TYPE 5 ///< Switching Intra 1.175 +#define FF_SP_TYPE 6 ///< Switching Predicted 1.176 +#define FF_BI_TYPE 7 1.177 + 1.178 +#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type 1.179 +#define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4) 1.180 +#define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16) 1.181 +#define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM) 1.182 +#define IS_INTRA(a) ((a)&7) 1.183 +#define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8)) 1.184 +#define IS_SKIP(a) ((a)&MB_TYPE_SKIP) 1.185 +#define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM) 1.186 +#define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED) 1.187 +#define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2) 1.188 +#define IS_GMC(a) ((a)&MB_TYPE_GMC) 1.189 +#define IS_16X16(a) ((a)&MB_TYPE_16x16) 1.190 +#define IS_16X8(a) ((a)&MB_TYPE_16x8) 1.191 +#define IS_8X16(a) ((a)&MB_TYPE_8x16) 1.192 +#define IS_8X8(a) ((a)&MB_TYPE_8x8) 1.193 +#define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused 1.194 +#define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused 1.195 +#define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused 1.196 +#define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused 1.197 +#define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED) 1.198 +#define IS_QUANT(a) ((a)&MB_TYPE_QUANT) 1.199 +#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list)))) 1.200 +#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 1.201 +#define HAS_CBP(a) ((a)&MB_TYPE_CBP) 1.202 + 1.203 + 1.204 +#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ 1.205 + /* lower 16 bits - CPU features */ 1.206 +#define FF_MM_MMX 0x0001 ///< standard MMX 1.207 +#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW 1.208 +#define FF_MM_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext 1.209 +#define FF_MM_SSE 0x0008 ///< SSE functions 1.210 +#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions 1.211 +#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt 1.212 +#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions 1.213 +#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions 1.214 +#define FF_MM_SSE4 0x0100 ///< Penryn SSE4.1 functions 1.215 +#define FF_MM_SSE42 0x0200 ///< Nehalem SSE4.2 functions 1.216 +#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT 1.217 +#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec 1.218 + 1.219 + 1.220 +/** 1.221 +* Sequence parameter set 1.222 +*/ 1.223 +typedef struct SPS{ 1.224 + 1.225 + int profile_idc; 1.226 + int level_idc; 1.227 + int chroma_format_idc; 1.228 + int transform_bypass; ///< qpprime_y_zero_transform_bypass_flag 1.229 + int log2_max_frame_num; ///< log2_max_frame_num_minus4 + 4 1.230 + int poc_type; ///< pic_order_cnt_type 1.231 + int log2_max_poc_lsb; ///< log2_max_pic_order_cnt_lsb_minus4 1.232 + int delta_pic_order_always_zero_flag; 1.233 + int offset_for_non_ref_pic; 1.234 + int offset_for_top_to_bottom_field; 1.235 + int poc_cycle_length; ///< num_ref_frames_in_pic_order_cnt_cycle 1.236 + int ref_frame_count; ///< num_ref_frames 1.237 + int gaps_in_frame_num_allowed_flag; 1.238 + int mb_width; ///< pic_width_in_mbs_minus1 + 1 1.239 + int mb_height; ///< pic_height_in_map_units_minus1 + 1 1.240 + int frame_mbs_only_flag; 1.241 + int mb_aff; ///<mb_adaptive_frame_field_flag 1.242 + int direct_8x8_inference_flag; 1.243 + int crop; ///< frame_cropping_flag 1.244 + unsigned int crop_left; ///< frame_cropping_rect_left_offset 1.245 + unsigned int crop_right; ///< frame_cropping_rect_right_offset 1.246 + unsigned int crop_top; ///< frame_cropping_rect_top_offset 1.247 + unsigned int crop_bottom; ///< frame_cropping_rect_bottom_offset 1.248 + int vui_parameters_present_flag; 1.249 + int num,den; 1.250 + 1.251 + int video_signal_type_present_flag; 1.252 + int full_range; 1.253 + int colour_description_present_flag; 1.254 + enum AVColorPrimaries color_primaries; 1.255 + enum AVColorTransferCharacteristic color_trc; 1.256 + enum AVColorSpace colorspace; 1.257 + int timing_info_present_flag; 1.258 + uint32_t num_units_in_tick; 1.259 + uint32_t time_scale; 1.260 + int fixed_frame_rate_flag; 1.261 + short offset_for_ref_frame[256]; //FIXME dyn aloc? 1.262 + int bitstream_restriction_flag; 1.263 + int num_reorder_frames; 1.264 + int scaling_matrix_present; 1.265 + uint8_t scaling_matrix4[6][16]; 1.266 + uint8_t scaling_matrix8[2][64]; 1.267 + int nal_hrd_parameters_present_flag; 1.268 + int vcl_hrd_parameters_present_flag; 1.269 + int pic_struct_present_flag; 1.270 + int time_offset_length; 1.271 + int cpb_cnt; ///< See H.264 E.1.2 1.272 + int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 +1 1.273 + int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 1.274 + int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 1.275 + int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 1.276 + int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 1.277 + int residual_color_transform_flag; ///< residual_colour_transform_flag 1.278 +}SPS; 1.279 + 1.280 +/** 1.281 +* Picture parameter set 1.282 +*/ 1.283 +typedef struct PPS{ 1.284 + unsigned int sps_id; 1.285 + int cabac; ///< entropy_coding_mode_flag 1.286 + int pic_order_present; ///< pic_order_present_flag 1.287 + int slice_group_count; ///< num_slice_groups_minus1 + 1 1.288 + int mb_slice_group_map_type; 1.289 + unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1 1.290 + int weighted_pred; ///< weighted_pred_flag 1.291 + int weighted_bipred_idc; 1.292 + int init_qp; ///< pic_init_qp_minus26 + 26 1.293 + int init_qs; ///< pic_init_qs_minus26 + 26 1.294 + int chroma_qp_index_offset[2]; 1.295 + int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag 1.296 + int constrained_intra_pred; ///< constrained_intra_pred_flag 1.297 + int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag 1.298 + int transform_8x8_mode; ///< transform_8x8_mode_flag 1.299 + uint8_t scaling_matrix4[6][16]; 1.300 + uint8_t scaling_matrix8[2][64]; 1.301 + uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table 1.302 + int chroma_qp_diff; 1.303 +}PPS; 1.304 + 1.305 +typedef struct TopBorder{ 1.306 + uint8_t unfiltered_y[16]; 1.307 + uint8_t unfiltered_cb[8]; 1.308 + uint8_t unfiltered_cr[8]; 1.309 + 1.310 + uint8_t top_borders_y[16*4]; 1.311 + uint8_t top_borders_cb[8*2]; 1.312 + uint8_t top_borders_cr[8*2]; 1.313 +}TopBorder; 1.314 + 1.315 +typedef struct LeftBorder{ 1.316 + uint8_t unfiltered_y[17]; 1.317 + uint8_t unfiltered_cb[9]; 1.318 + uint8_t unfiltered_cr[9]; 1.319 +}LeftBorder; 1.320 + 1.321 +typedef struct H264Mb { 1.322 + //variables copied in after cabac decoding 1.323 + int16_t mb_x, mb_y; 1.324 + int32_t mb_type; 1.325 + 1.326 + uint16_t cbp; // coded block pattern, idct, deblock 1.327 + int8_t qscale_mb_xy; // qp, deblock 1.328 + int8_t qscale_left_mb_xy; //not required 1.329 + int8_t qscale_top_mb_xy; 1.330 + 1.331 + DECLARE_ALIGNED(8, uint16_t, sub_mb_type[4]); 1.332 + DECLARE_ALIGNED(8, uint8_t, non_zero_count[24]); //idct deblock 1.333 + DECLARE_ALIGNED(16, int16_t, mb[16*24]); //coeffs, idct 1.334 + 1.335 + union{ 1.336 + struct { 1.337 + DECLARE_ALIGNED(8, int8_t, ref_index[2][4]); //mc, deblock 1.338 + DECLARE_ALIGNED(16, int16_t, mvd[2][16][2]); //mc, deblock 1.339 + }; 1.340 + struct { 1.341 + DECLARE_ALIGNED(8, int8_t, intra4x4_pred_mode[16]); //intra, deblock 1.342 + int8_t chroma_pred_mode; //intra 1.343 + int8_t intra16x16_pred_mode; //intra, deblock 1.344 + }; 1.345 + }; 1.346 + 1.347 +#if OMPSS 1.348 + DECLARE_ALIGNED(8, uint8_t, top_border[16+ 2*8]); 1.349 + DECLARE_ALIGNED(8, uint8_t, top_border_next[8]); 1.350 + DECLARE_ALIGNED(8, uint8_t, left_border[17+2*9]); 1.351 + int8_t intra4x4_pred_mode_left[4]; 1.352 +#endif 1.353 + 1.354 +} H264Mb; 1.355 + 1.356 +typedef struct RawFrame { 1.357 + uint8_t *data; 1.358 + int size; 1.359 + unsigned int data_size; 1.360 + int64_t pos; ///< byte position in stream, -1 if unknown 1.361 + int state; 1.362 +} RawFrame; 1.363 + 1.364 +typedef struct PictureInfo{ 1.365 + int ref_poc[2][16]; ///< h264 POCs of the frames used as reference 1.366 + int ref_count[2]; ///< number of entries in ref_poc 1.367 + int poc; ///< h264 frame POC 1.368 + int frame_num; ///< h264 frame_num (raw frame_num from slice header) 1.369 + int pic_id; 1.370 + int long_ref; 1.371 + int cpn; ///coded picture number 1.372 + int slice_type_nos; 1.373 +// int key_frame; 1.374 +// int mmco_reset; ///< h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET. 1.375 + 1.376 + int reference; //Set to 4 for delayed, non-reference frames. 1-3 for reference. FIXME 1.377 + 1.378 +}PictureInfo; 1.379 + 1.380 +typedef struct DecodedPicture{ 1.381 + int16_t (*motion_val[2])[2]; 1.382 + int16_t (*motion_val_base[2])[2]; 1.383 + 1.384 + /** 1.385 + * motion reference frame index 1.386 + * the order in which these are stored can depend on the codec. 1.387 + * - encoding: Set by user. 1.388 + * - decoding: Set by libavcodec. 1.389 + */ 1.390 + int8_t *ref_index[2]; 1.391 + uint32_t *mb_type; //mb_type_base + mb_width + 2 1.392 + uint32_t *mb_type_base; 1.393 + 1.394 + int8_t *intra4x4_pred_mode; 1.395 + int8_t *non_zero_count; 1.396 + 1.397 + uint8_t *data[3]; //point to first pixel in the frame 1.398 + int linesize[3]; 1.399 + uint8_t *base[3]; //base of picture planes 1.400 + 1.401 + int cpn; /// coded picture number 1.402 + int poc; ///< h264 frame POC 1.403 + int reference; // 0 -> free, 1 -> needs to be displayed, 2 -> needed for reference, 3 -> 1 && 2 1.404 + int key_frame; 1.405 + int mmco_reset; ///< h264 MMCO_RESET set this 1. Reordering code must not mix pictures before and after MMCO_RESET. 1.406 + 1.407 +} DecodedPicture; 1.408 + 1.409 + 1.410 +#endif /* AVCODEC_AVCODEC_H */
