Unified · Split
| @@ -37,14 +37,14 @@ · 36 unmodified lines | ||
| 37 | 37 | #include "rectangle.h" |
| 38 | 38 | |
| 39 | 39 | #define interlaced_dct interlaced_dct_is_a_bad_name |
| 40 | −#define mb_intra mb_intra_is_not_initialized_see_mb_type | |
| 40 | +#define mb_intra mb_intra_is_not_initialized_see_mb_type | |
| 41 | 41 | |
| 42 | −#define MAX_SPS_COUNT 32 | |
| 43 | −#define MAX_PPS_COUNT 256 | |
| 42 | +#define MAX_SPS_COUNT 32 | |
| 43 | +#define MAX_PPS_COUNT 256 | |
| 44 | 44 | |
| 45 | −#define MAX_MMCO_COUNT 66 | |
| 45 | +#define MAX_MMCO_COUNT 66 | |
| 46 | 46 | |
| 47 | −#define MAX_DELAYED_PIC_COUNT 16 | |
| 47 | +#define MAX_DELAYED_PIC_COUNT 16 | |
| 48 | 48 | |
| 49 | 49 | /* Compiling in interlaced support reduces the speed |
| 50 | 50 | * of progressive decoding by about 2%. */ |
| @@ -59,25 +59,25 @@ · 8 unmodified lines | ||
| 59 | 59 | #define MAX_SLICES 16 |
| 60 | 60 | |
| 61 | 61 | #ifdef ALLOW_INTERLACE |
| 62 | −#define MB_MBAFF h->mb_mbaff | |
| 63 | −#define MB_FIELD h->mb_field_decoding_flag | |
| 62 | +#define MB_MBAFF h->mb_mbaff | |
| 63 | +#define MB_FIELD h->mb_field_decoding_flag | |
| 64 | 64 | #define FRAME_MBAFF h->mb_aff_frame |
| 65 | 65 | #define FIELD_PICTURE (s->picture_structure != PICT_FRAME) |
| 66 | 66 | #define LEFT_MBS 2 |
| 67 | −#define LTOP 0 | |
| 68 | −#define LBOT 1 | |
| 69 | −#define LEFT(i) (i) | |
| 67 | +#define LTOP 0 | |
| 68 | +#define LBOT 1 | |
| 69 | +#define LEFT(i) (i) | |
| 70 | 70 | #else |
| 71 | −#define MB_MBAFF 0 | |
| 72 | −#define MB_FIELD 0 | |
| 73 | −#define FRAME_MBAFF 0 | |
| 71 | +#define MB_MBAFF 0 | |
| 72 | +#define MB_FIELD 0 | |
| 73 | +#define FRAME_MBAFF 0 | |
| 74 | 74 | #define FIELD_PICTURE 0 |
| 75 | 75 | #undef IS_INTERLACED |
| 76 | 76 | #define IS_INTERLACED(mb_type) 0 |
| 77 | 77 | #define LEFT_MBS 1 |
| 78 | −#define LTOP 0 | |
| 79 | −#define LBOT 0 | |
| 80 | −#define LEFT(i) 0 | |
| 78 | +#define LTOP 0 | |
| 79 | +#define LBOT 0 | |
| 80 | +#define LEFT(i) 0 | |
| 81 | 81 | #endif |
| 82 | 82 | #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE) |
| 83 | 83 | |
| @@ -88,9 +88,9 @@ · 4 unmodified lines | ||
| 88 | 88 | #define CHROMA422 (h->sps.chroma_format_idc == 2) |
| 89 | 89 | #define CHROMA444 (h->sps.chroma_format_idc == 3) |
| 90 | 90 | |
| 91 | −#define EXTENDED_SAR 255 | |
| 91 | +#define EXTENDED_SAR 255 | |
| 92 | 92 | |
| 93 | −#define MB_TYPE_REF0 MB_TYPE_ACPRED //dirty but it fits in 16 bit | |
| 93 | +#define MB_TYPE_REF0 MB_TYPE_ACPRED // dirty but it fits in 16 bit | |
| 94 | 94 | #define MB_TYPE_8x8DCT 0x01000000 |
| 95 | 95 | #define IS_REF0(a) ((a) & MB_TYPE_REF0) |
| 96 | 96 | #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT) |
| @@ -101,11 +101,11 @@ · 4 unmodified lines | ||
| 101 | 101 | */ |
| 102 | 102 | #define DELAYED_PIC_REF 4 |
| 103 | 103 | |
| 104 | −#define QP_MAX_NUM (51 + 2*6) // The maximum supported qp | |
| 104 | +#define QP_MAX_NUM (51 + 2 * 6) // The maximum supported qp | |
| 105 | 105 | |
| 106 | 106 | /* NAL unit types */ |
| 107 | 107 | enum { |
| 108 | − NAL_SLICE=1, | |
| 108 | + NAL_SLICE = 1, | |
| 109 | 109 | NAL_DPA, |
| 110 | 110 | NAL_DPB, |
| 111 | 111 | NAL_DPC, |
| @@ -118,17 +118,17 @@ enum { · 6 unmodified lines | ||
| 118 | 118 | NAL_END_STREAM, |
| 119 | 119 | NAL_FILLER_DATA, |
| 120 | 120 | NAL_SPS_EXT, |
| 121 | − NAL_AUXILIARY_SLICE=19 | |
| 121 | + NAL_AUXILIARY_SLICE = 19 | |
| 122 | 122 | }; |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * SEI message types |
| 126 | 126 | */ |
| 127 | 127 | typedef enum { |
| 128 | − SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) | |
| 129 | − SEI_TYPE_PIC_TIMING = 1, ///< picture timing | |
| 130 | − SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data | |
| 131 | − SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) | |
| 128 | + SEI_BUFFERING_PERIOD = 0, ///< buffering period (H.264, D.1.1) | |
| 129 | + SEI_TYPE_PIC_TIMING = 1, ///< picture timing | |
| 130 | + SEI_TYPE_USER_DATA_UNREGISTERED = 5, ///< unregistered user data | |
| 131 | + SEI_TYPE_RECOVERY_POINT = 6 ///< recovery point (frame # to decoder sync) | |
| 132 | 132 | } SEI_Type; |
| 133 | 133 | |
| 134 | 134 | /** |
| @@ -149,8 +149,7 @@ typedef enum { · 14 unmodified lines | ||
| 149 | 149 | /** |
| 150 | 150 | * Sequence parameter set |
| 151 | 151 | */ |
| 152 | −typedef struct SPS{ | |
| 153 | − | |
| 152 | +typedef struct SPS { | |
| 154 | 153 | int profile_idc; |
| 155 | 154 | int level_idc; |
| 156 | 155 | int chroma_format_idc; |
| @@ -167,9 +166,9 @@ typedef struct SPS{ · 10 unmodified lines | ||
| 167 | 166 | int mb_width; ///< pic_width_in_mbs_minus1 + 1 |
| 168 | 167 | int mb_height; ///< pic_height_in_map_units_minus1 + 1 |
| 169 | 168 | int frame_mbs_only_flag; |
| 170 | − int mb_aff; ///<mb_adaptive_frame_field_flag | |
| 169 | + int mb_aff; ///< mb_adaptive_frame_field_flag | |
| 171 | 170 | int direct_8x8_inference_flag; |
| 172 | − int crop; ///< frame_cropping_flag | |
| 171 | + int crop; ///< frame_cropping_flag | |
| 173 | 172 | unsigned int crop_left; ///< frame_cropping_rect_left_offset |
| 174 | 173 | unsigned int crop_right; ///< frame_cropping_rect_right_offset |
| 175 | 174 | unsigned int crop_top; ///< frame_cropping_rect_top_offset |
| @@ -186,7 +185,7 @@ typedef struct SPS{ · 10 unmodified lines | ||
| 186 | 185 | uint32_t num_units_in_tick; |
| 187 | 186 | uint32_t time_scale; |
| 188 | 187 | int fixed_frame_rate_flag; |
| 189 | − short offset_for_ref_frame[256]; //FIXME dyn aloc? | |
| 188 | + short offset_for_ref_frame[256]; // FIXME dyn aloc? | |
| 190 | 189 | int bitstream_restriction_flag; |
| 191 | 190 | int num_reorder_frames; |
| 192 | 191 | int scaling_matrix_present; |
| @@ -196,20 +195,20 @@ typedef struct SPS{ · 3 unmodified lines | ||
| 196 | 195 | int vcl_hrd_parameters_present_flag; |
| 197 | 196 | int pic_struct_present_flag; |
| 198 | 197 | int time_offset_length; |
| 199 | − int cpb_cnt; ///< See H.264 E.1.2 | |
| 200 | − int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 +1 | |
| 201 | − int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 | |
| 202 | − int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 | |
| 203 | − int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 | |
| 204 | − int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 | |
| 205 | − int residual_color_transform_flag; ///< residual_colour_transform_flag | |
| 206 | − int constraint_set_flags; ///< constraint_set[0-3]_flag | |
| 207 | −}SPS; | |
| 198 | + int cpb_cnt; ///< See H.264 E.1.2 | |
| 199 | + int initial_cpb_removal_delay_length; ///< initial_cpb_removal_delay_length_minus1 + 1 | |
| 200 | + int cpb_removal_delay_length; ///< cpb_removal_delay_length_minus1 + 1 | |
| 201 | + int dpb_output_delay_length; ///< dpb_output_delay_length_minus1 + 1 | |
| 202 | + int bit_depth_luma; ///< bit_depth_luma_minus8 + 8 | |
| 203 | + int bit_depth_chroma; ///< bit_depth_chroma_minus8 + 8 | |
| 204 | + int residual_color_transform_flag; ///< residual_colour_transform_flag | |
| 205 | + int constraint_set_flags; ///< constraint_set[0-3]_flag | |
| 206 | +} SPS; | |
| 208 | 207 | |
| 209 | 208 | /** |
| 210 | 209 | * Picture parameter set |
| 211 | 210 | */ |
| 212 | −typedef struct PPS{ | |
| 211 | +typedef struct PPS { | |
| 213 | 212 | unsigned int sps_id; |
| 214 | 213 | int cabac; ///< entropy_coding_mode_flag |
| 215 | 214 | int pic_order_present; ///< pic_order_present_flag |
| @@ -222,20 +221,20 @@ typedef struct PPS{ · 6 unmodified lines | ||
| 222 | 221 | int init_qs; ///< pic_init_qs_minus26 + 26 |
| 223 | 222 | int chroma_qp_index_offset[2]; |
| 224 | 223 | int deblocking_filter_parameters_present; ///< deblocking_filter_parameters_present_flag |
| 225 | − int constrained_intra_pred; ///< constrained_intra_pred_flag | |
| 226 | − int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag | |
| 227 | − int transform_8x8_mode; ///< transform_8x8_mode_flag | |
| 224 | + int constrained_intra_pred; ///< constrained_intra_pred_flag | |
| 225 | + int redundant_pic_cnt_present; ///< redundant_pic_cnt_present_flag | |
| 226 | + int transform_8x8_mode; ///< transform_8x8_mode_flag | |
| 228 | 227 | uint8_t scaling_matrix4[6][16]; |
| 229 | 228 | uint8_t scaling_matrix8[6][64]; |
| 230 | − uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table | |
| 229 | + uint8_t chroma_qp_table[2][64]; ///< pre-scaled (with chroma_qp_index_offset) version of qp_table | |
| 231 | 230 | int chroma_qp_diff; |
| 232 | −}PPS; | |
| 231 | +} PPS; | |
| 233 | 232 | |
| 234 | 233 | /** |
| 235 | 234 | * Memory management control operation opcode. |
| 236 | 235 | */ |
| 237 | −typedef enum MMCOOpcode{ | |
| 238 | − MMCO_END=0, | |
| 236 | +typedef enum MMCOOpcode { | |
| 237 | + MMCO_END = 0, | |
| 239 | 238 | MMCO_SHORT2UNUSED, |
| 240 | 239 | MMCO_LONG2UNUSED, |
| 241 | 240 | MMCO_SHORT2LONG, |
| @@ -247,7 +246,7 @@ typedef enum MMCOOpcode{ · 5 unmodified lines | ||
| 247 | 246 | /** |
| 248 | 247 | * Memory management control operation. |
| 249 | 248 | */ |
| 250 | −typedef struct MMCO{ | |
| 249 | +typedef struct MMCO { | |
| 251 | 250 | MMCOOpcode opcode; |
| 252 | 251 | int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num) |
| 253 | 252 | int long_arg; ///< index, pic_num, or num long refs depending on opcode |
| @@ -256,18 +255,18 @@ typedef struct MMCO{ · 2 unmodified lines | ||
| 256 | 255 | /** |
| 257 | 256 | * H264Context |
| 258 | 257 | */ |
| 259 | −typedef struct H264Context{ | |
| 258 | +typedef struct H264Context { | |
| 260 | 259 | MpegEncContext s; |
| 261 | 260 | H264DSPContext h264dsp; |
| 262 | 261 | int pixel_shift; ///< 0 for 8-bit H264, 1 for high-bit-depth H264 |
| 263 | − int chroma_qp[2]; //QPc | |
| 262 | + int chroma_qp[2]; // QPc | |
| 264 | 263 | |
| 265 | 264 | int qp_thresh; ///< QP threshold to skip loopfilter |
| 266 | 265 | |
| 267 | 266 | int prev_mb_skipped; |
| 268 | 267 | int next_mb_skipped; |
| 269 | 268 | |
| 270 | − //prediction stuff | |
| 269 | + // prediction stuff | |
| 271 | 270 | int chroma_pred_mode; |
| 272 | 271 | int intra16x16_pred_mode; |
| 273 | 272 | |
| @@ -281,32 +280,32 @@ typedef struct H264Context{ · 7 unmodified lines | ||
| 281 | 280 | int topright_type; |
| 282 | 281 | int left_type[LEFT_MBS]; |
| 283 | 282 | |
| 284 | − const uint8_t * left_block; | |
| 283 | + const uint8_t *left_block; | |
| 285 | 284 | int topleft_partition; |
| 286 | 285 | |
| 287 | − int8_t intra4x4_pred_mode_cache[5*8]; | |
| 288 | − int8_t (*intra4x4_pred_mode); | |
| 286 | + int8_t intra4x4_pred_mode_cache[5 * 8]; | |
| 287 | + int8_t(*intra4x4_pred_mode); | |
| 289 | 288 | H264PredContext hpc; |
| 290 | 289 | unsigned int topleft_samples_available; |
| 291 | 290 | unsigned int top_samples_available; |
| 292 | 291 | unsigned int topright_samples_available; |
| 293 | 292 | unsigned int left_samples_available; |
| 294 | − uint8_t (*top_borders[2])[(16*3)*2]; | |
| 293 | + uint8_t (*top_borders[2])[(16 * 3) * 2]; | |
| 295 | 294 | |
| 296 | 295 | /** |
| 297 | 296 | * non zero coeff count cache. |
| 298 | 297 | * is 64 if not available. |
| 299 | 298 | */ |
| 300 | − DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15*8]; | |
| 299 | + DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8]; | |
| 301 | 300 | |
| 302 | 301 | uint8_t (*non_zero_count)[48]; |
| 303 | 302 | |
| 304 | 303 | /** |
| 305 | 304 | * Motion vector cache. |
| 306 | 305 | */ |
| 307 | − DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5*8][2]; | |
| 308 | − DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5*8]; | |
| 309 | −#define LIST_NOT_USED -1 //FIXME rename? | |
| 306 | + DECLARE_ALIGNED(16, int16_t, mv_cache)[2][5 * 8][2]; | |
| 307 | + DECLARE_ALIGNED(8, int8_t, ref_cache)[2][5 * 8]; | |
| 308 | +#define LIST_NOT_USED -1 // FIXME rename? | |
| 310 | 309 | #define PART_NOT_AVAILABLE -2 |
| 311 | 310 | |
| 312 | 311 | /** |
| @@ -318,13 +317,13 @@ typedef struct H264Context{ · 5 unmodified lines | ||
| 318 | 317 | * block_offset[ 0..23] for frame macroblocks |
| 319 | 318 | * block_offset[24..47] for field macroblocks |
| 320 | 319 | */ |
| 321 | − int block_offset[2*(16*3)]; | |
| 320 | + int block_offset[2 * (16 * 3)]; | |
| 322 | 321 | |
| 323 | − uint32_t *mb2b_xy; //FIXME are these 4 a good idea? | |
| 322 | + uint32_t *mb2b_xy; // FIXME are these 4 a good idea? | |
| 324 | 323 | uint32_t *mb2br_xy; |
| 325 | − int b_stride; //FIXME use s->b4_stride | |
| 324 | + int b_stride; // FIXME use s->b4_stride | |
| 326 | 325 | |
| 327 | − int mb_linesize; ///< may be equal to s->linesize or s->linesize*2, for mbaff | |
| 326 | + int mb_linesize; ///< may be equal to s->linesize or s->linesize * 2, for mbaff | |
| 328 | 327 | int mb_uvlinesize; |
| 329 | 328 | |
| 330 | 329 | int emu_edge_width; |
| @@ -335,32 +334,32 @@ typedef struct H264Context{ · 4 unmodified lines | ||
| 335 | 334 | /** |
| 336 | 335 | * current pps |
| 337 | 336 | */ |
| 338 | − PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? | |
| 337 | + PPS pps; // FIXME move to Picture perhaps? (->no) do we need that? | |
| 339 | 338 | |
| 340 | − uint32_t dequant4_buffer[6][QP_MAX_NUM+1][16]; //FIXME should these be moved down? | |
| 341 | − uint32_t dequant8_buffer[6][QP_MAX_NUM+1][64]; | |
| 342 | − uint32_t (*dequant4_coeff[6])[16]; | |
| 343 | − uint32_t (*dequant8_coeff[6])[64]; | |
| 339 | + uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down? | |
| 340 | + uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64]; | |
| 341 | + uint32_t(*dequant4_coeff[6])[16]; | |
| 342 | + uint32_t(*dequant8_coeff[6])[64]; | |
| 344 | 343 | |
| 345 | 344 | int slice_num; |
| 346 | − uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 | |
| 345 | + uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 | |
| 347 | 346 | int slice_type; |
| 348 | − int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) | |
| 347 | + int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) | |
| 349 | 348 | int slice_type_fixed; |
| 350 | 349 | |
| 351 | − //interlacing specific flags | |
| 350 | + // interlacing specific flags | |
| 352 | 351 | int mb_aff_frame; |
| 353 | 352 | int mb_field_decoding_flag; |
| 354 | − int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag | |
| 353 | + int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag | |
| 355 | 354 | |
| 356 | 355 | DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4]; |
| 357 | 356 | |
| 358 | − //Weighted pred stuff | |
| 357 | + // Weighted pred stuff | |
| 359 | 358 | int use_weight; |
| 360 | 359 | int use_weight_chroma; |
| 361 | 360 | int luma_log2_weight_denom; |
| 362 | 361 | int chroma_log2_weight_denom; |
| 363 | − //The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss | |
| 362 | + // The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss | |
| 364 | 363 | int luma_weight[48][2][2]; |
| 365 | 364 | int chroma_weight[48][2][2][2]; |
| 366 | 365 | int implicit_weight[48][48][2]; |
| @@ -370,48 +369,48 @@ typedef struct H264Context{ · 3 unmodified lines | ||
| 370 | 369 | int col_fieldoff; |
| 371 | 370 | int dist_scale_factor[16]; |
| 372 | 371 | int dist_scale_factor_field[2][32]; |
| 373 | − int map_col_to_list0[2][16+32]; | |
| 374 | − int map_col_to_list0_field[2][2][16+32]; | |
| 372 | + int map_col_to_list0[2][16 + 32]; | |
| 373 | + int map_col_to_list0_field[2][2][16 + 32]; | |
| 375 | 374 | |
| 376 | 375 | /** |
| 377 | 376 | * num_ref_idx_l0/1_active_minus1 + 1 |
| 378 | 377 | */ |
| 379 | − unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | |
| 378 | + unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | |
| 380 | 379 | unsigned int list_count; |
| 381 | − uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type | |
| 382 | − Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | |
| 383 | − Reordered version of default_ref_list | |
| 384 | − according to picture reordering in slice header */ | |
| 385 | − int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | |
| 380 | + uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type | |
| 381 | + Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | |
| 382 | + * Reordered version of default_ref_list | |
| 383 | + * according to picture reordering in slice header */ | |
| 384 | + int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | |
| 386 | 385 | |
| 387 | − //data partitioning | |
| 386 | + // data partitioning | |
| 388 | 387 | GetBitContext intra_gb; |
| 389 | 388 | GetBitContext inter_gb; |
| 390 | 389 | GetBitContext *intra_gb_ptr; |
| 391 | 390 | GetBitContext *inter_gb_ptr; |
| 392 | 391 | |
| 393 | − DECLARE_ALIGNED(16, DCTELEM, mb)[16*48*2]; ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space. | |
| 394 | − DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16*2]; | |
| 395 | − DCTELEM mb_padding[256*2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb | |
| 392 | + DECLARE_ALIGNED(16, DCTELEM, mb)[16 * 48 * 2]; ///< as a dct coeffecient is int32_t in high depth, we need to reserve twice the space. | |
| 393 | + DECLARE_ALIGNED(16, DCTELEM, mb_luma_dc)[3][16 * 2]; | |
| 394 | + DCTELEM mb_padding[256 * 2]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not too large or ensure that there is some unused stuff after mb | |
| 396 | 395 | |
| 397 | 396 | /** |
| 398 | 397 | * Cabac |
| 399 | 398 | */ |
| 400 | 399 | CABACContext cabac; |
| 401 | − uint8_t cabac_state[1024]; | |
| 400 | + uint8_t cabac_state[1024]; | |
| 402 | 401 | |
| 403 | − /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */ | |
| 404 | − uint16_t *cbp_table; | |
| 402 | + /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0, 1, 2), 0x0? luma_cbp */ | |
| 403 | + uint16_t *cbp_table; | |
| 405 | 404 | int cbp; |
| 406 | 405 | int top_cbp; |
| 407 | 406 | int left_cbp; |
| 408 | 407 | /* chroma_pred_mode for i4x4 or i16x16, else 0 */ |
| 409 | − uint8_t *chroma_pred_mode_table; | |
| 410 | − int last_qscale_diff; | |
| 411 | − uint8_t (*mvd_table[2])[2]; | |
| 412 | − DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5*8][2]; | |
| 413 | − uint8_t *direct_table; | |
| 414 | − uint8_t direct_cache[5*8]; | |
| 408 | + uint8_t *chroma_pred_mode_table; | |
| 409 | + int last_qscale_diff; | |
| 410 | + uint8_t (*mvd_table[2])[2]; | |
| 411 | + DECLARE_ALIGNED(16, uint8_t, mvd_cache)[2][5 * 8][2]; | |
| 412 | + uint8_t *direct_table; | |
| 413 | + uint8_t direct_cache[5 * 8]; | |
| 415 | 414 | |
| 416 | 415 | uint8_t zigzag_scan[16]; |
| 417 | 416 | uint8_t zigzag_scan8x8[64]; |
| @@ -432,13 +431,13 @@ typedef struct H264Context{ · 14 unmodified lines | ||
| 432 | 431 | |
| 433 | 432 | int is_complex; |
| 434 | 433 | |
| 435 | − //deblock | |
| 436 | − int deblocking_filter; ///< disable_deblocking_filter_idc with 1<->0 | |
| 434 | + // deblock | |
| 435 | + int deblocking_filter; ///< disable_deblocking_filter_idc with 1 <-> 0 | |
| 437 | 436 | int slice_alpha_c0_offset; |
| 438 | 437 | int slice_beta_offset; |
| 439 | 438 | |
| 440 | −//============================================================= | |
| 441 | − //Things below are not used in the MB or more inner code | |
| 439 | + // ============================================================= | |
| 440 | + // Things below are not used in the MB or more inner code | |
| 442 | 441 | |
| 443 | 442 | int nal_ref_idc; |
| 444 | 443 | int nal_unit_type; |
| @@ -448,37 +447,36 @@ typedef struct H264Context{ · 3 unmodified lines | ||
| 448 | 447 | /** |
| 449 | 448 | * Used to parse AVC variant of h264 |
| 450 | 449 | */ |
| 451 | − int is_avc; ///< this flag is != 0 if codec is avc1 | |
| 452 | − int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | |
| 453 | − int got_first; ///< this flag is != 0 if we've parsed a frame | |
| 450 | + int is_avc; ///< this flag is != 0 if codec is avc1 | |
| 451 | + int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | |
| 452 | + int got_first; ///< this flag is != 0 if we've parsed a frame | |
| 454 | 453 | |
| 455 | 454 | SPS *sps_buffers[MAX_SPS_COUNT]; |
| 456 | 455 | PPS *pps_buffers[MAX_PPS_COUNT]; |
| 457 | 456 | |
| 458 | − int dequant_coeff_pps; ///< reinit tables when pps changes | |
| 457 | + int dequant_coeff_pps; ///< reinit tables when pps changes | |
| 459 | 458 | |
| 460 | 459 | uint16_t *slice_table_base; |
| 461 | 460 | |
| 462 | − | |
| 463 | − //POC stuff | |
| 461 | + // POC stuff | |
| 464 | 462 | int poc_lsb; |
| 465 | 463 | int poc_msb; |
| 466 | 464 | int delta_poc_bottom; |
| 467 | 465 | int delta_poc[2]; |
| 468 | 466 | int frame_num; |
| 469 | − int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 | |
| 470 | − int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 | |
| 471 | − int frame_num_offset; ///< for POC type 2 | |
| 472 | − int prev_frame_num_offset; ///< for POC type 2 | |
| 473 | − int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 | |
| 467 | + int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 | |
| 468 | + int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 | |
| 469 | + int frame_num_offset; ///< for POC type 2 | |
| 470 | + int prev_frame_num_offset; ///< for POC type 2 | |
| 471 | + int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 | |
| 474 | 472 | |
| 475 | 473 | /** |
| 476 | − * frame_num for frames or 2*frame_num+1 for field pics. | |
| 474 | + * frame_num for frames or 2 * frame_num + 1 for field pics. | |
| 477 | 475 | */ |
| 478 | 476 | int curr_pic_num; |
| 479 | 477 | |
| 480 | 478 | /** |
| 481 | − * max_frame_num or 2*max_frame_num for field pics. | |
| 479 | + * max_frame_num or 2 * max_frame_num for field pics. | |
| 482 | 480 | */ |
| 483 | 481 | int max_pic_num; |
| 484 | 482 | |
| @@ -487,7 +485,7 @@ typedef struct H264Context{ · 2 unmodified lines | ||
| 487 | 485 | Picture *short_ref[32]; |
| 488 | 486 | Picture *long_ref[32]; |
| 489 | 487 | Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture |
| 490 | − Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size? | |
| 488 | + Picture *delayed_pic[MAX_DELAYED_PIC_COUNT + 2]; // FIXME size? | |
| 491 | 489 | int last_pocs[MAX_DELAYED_PIC_COUNT]; |
| 492 | 490 | Picture *next_output_pic; |
| 493 | 491 | int outputed_poc; |
| @@ -500,10 +498,10 @@ typedef struct H264Context{ · 6 unmodified lines | ||
| 500 | 498 | int mmco_index; |
| 501 | 499 | int mmco_reset; |
| 502 | 500 | |
| 503 | − int long_ref_count; ///< number of actual long term references | |
| 504 | − int short_ref_count; ///< number of actual short term references | |
| 501 | + int long_ref_count; ///< number of actual long term references | |
| 502 | + int short_ref_count; ///< number of actual short term references | |
| 505 | 503 | |
| 506 | − int cabac_init_idc; | |
| 504 | + int cabac_init_idc; | |
| 507 | 505 | |
| 508 | 506 | /** |
| 509 | 507 | * @name Members for slice based multithreading |
| @@ -572,18 +570,17 @@ typedef struct H264Context{ · 62 unmodified lines | ||
| 572 | 570 | */ |
| 573 | 571 | int sei_recovery_frame_cnt; |
| 574 | 572 | |
| 575 | − int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag | |
| 576 | − int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag | |
| 573 | + int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag | |
| 574 | + int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag | |
| 577 | 575 | |
| 578 | 576 | // Timestamp stuff |
| 579 | − int sei_buffering_period_present; ///< Buffering period SEI flag | |
| 580 | − int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | |
| 577 | + int sei_buffering_period_present; ///< Buffering period SEI flag | |
| 578 | + int initial_cpb_removal_delay[32]; ///< Initial timestamps for CPBs | |
| 581 | 579 | |
| 582 | 580 | int cur_chroma_format_idc; |
| 583 | −}H264Context; | |
| 581 | +} H264Context; | |
| 584 | 582 | |
| 585 | − | |
| 586 | −extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM+1]; ///< One chroma qp table for each supported bit depth (8, 9, 10). | |
| 583 | +extern const uint8_t ff_h264_chroma_qp[3][QP_MAX_NUM + 1]; ///< One chroma qp table for each supported bit depth (8, 9, 10). | |
| 587 | 584 | extern const uint16_t ff_h264_mb_sizes[4]; |
| 588 | 585 | |
| 589 | 586 | /** |
| @@ -610,13 +607,16 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); · 20 unmodified lines | ||
| 610 | 607 | * Decode a network abstraction layer unit. |
| 611 | 608 | * @param consumed is the number of bytes used as input |
| 612 | 609 | * @param length is the length of the array |
| 613 | − * @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing? | |
| 610 | + * @param dst_length is the number of decoded bytes FIXME here | |
| 611 | + * or a decode rbsp tailing? | |
| 614 | 612 | * @return decoded bytes, might be src+1 if no escapes |
| 615 | 613 | */ |
| 616 | −const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length); | |
| 614 | +const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, | |
| 615 | + int *dst_length, int *consumed, int length); | |
| 617 | 616 | |
| 618 | 617 | /** |
| 619 | − * Free any data that may have been allocated in the H264 context like SPS, PPS etc. | |
| 618 | + * Free any data that may have been allocated in the H264 context | |
| 619 | + * like SPS, PPS etc. | |
| 620 | 620 | */ |
| 621 | 621 | av_cold void ff_h264_free_context(H264Context *h); |
| 622 | 622 | |
| @@ -649,14 +649,15 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); · 26 unmodified lines | ||
| 649 | 649 | |
| 650 | 650 | void ff_generate_sliding_window_mmcos(H264Context *h); |
| 651 | 651 | |
| 652 | − | |
| 653 | 652 | /** |
| 654 | − * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks. | |
| 653 | + * Check if the top & left blocks are available if needed & change the | |
| 654 | + * dc mode so it only uses the available blocks. | |
| 655 | 655 | */ |
| 656 | 656 | int ff_h264_check_intra4x4_pred_mode(H264Context *h); |
| 657 | 657 | |
| 658 | 658 | /** |
| 659 | − * Check if the top & left blocks are available if needed & change the dc mode so it only uses the available blocks. | |
| 659 | + * Check if the top & left blocks are available if needed & change the | |
| 660 | + * dc mode so it only uses the available blocks. | |
| 660 | 661 | */ |
| 661 | 662 | int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma); |
| 662 | 663 | |
| @@ -668,24 +669,28 @@ av_cold void ff_h264_decode_init_vlc(void); · 5 unmodified lines | ||
| 668 | 669 | |
| 669 | 670 | /** |
| 670 | 671 | * Decode a macroblock |
| 671 | − * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed | |
| 672 | + * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error | |
| 672 | 673 | */ |
| 673 | 674 | int ff_h264_decode_mb_cavlc(H264Context *h); |
| 674 | 675 | |
| 675 | 676 | /** |
| 676 | 677 | * Decode a CABAC coded macroblock |
| 677 | − * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR if an error is noticed | |
| 678 | + * @return 0 if OK, ER_AC_ERROR / ER_DC_ERROR / ER_MV_ERROR on error | |
| 678 | 679 | */ |
| 679 | 680 | int ff_h264_decode_mb_cabac(H264Context *h); |
| 680 | 681 | |
| 681 | 682 | void ff_h264_init_cabac_states(H264Context *h); |
| 682 | 683 | |
| 683 | −void ff_h264_direct_dist_scale_factor(H264Context * const h); | |
| 684 | −void ff_h264_direct_ref_list_init(H264Context * const h); | |
| 685 | −void ff_h264_pred_direct_motion(H264Context * const h, int *mb_type); | |
| 684 | +void ff_h264_direct_dist_scale_factor(H264Context *const h); | |
| 685 | +void ff_h264_direct_ref_list_init(H264Context *const h); | |
| 686 | +void ff_h264_pred_direct_motion(H264Context *const h, int *mb_type); | |
| 686 | 687 | |
| 687 | −void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); | |
| 688 | −void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize); | |
| 688 | +void ff_h264_filter_mb_fast(H264Context *h, int mb_x, int mb_y, | |
| 689 | + uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, | |
| 690 | + unsigned int linesize, unsigned int uvlinesize); | |
| 691 | +void ff_h264_filter_mb(H264Context *h, int mb_x, int mb_y, | |
| 692 | + uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, | |
| 693 | + unsigned int linesize, unsigned int uvlinesize); | |
| 689 | 694 | |
| 690 | 695 | /** |
| 691 | 696 | * Reset SEI values at the beginning of the frame. |
| @@ -694,16 +699,15 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint · 2 unmodified lines | ||
| 694 | 699 | */ |
| 695 | 700 | void ff_h264_reset_sei(H264Context *h); |
| 696 | 701 | |
| 697 | − | |
| 698 | 702 | /* |
| 699 | −o-o o-o | |
| 700 | − / / / | |
| 701 | −o-o o-o | |
| 702 | − ,---' | |
| 703 | −o-o o-o | |
| 704 | − / / / | |
| 705 | −o-o o-o | |
| 706 | −*/ | |
| 703 | + * o-o o-o | |
| 704 | + * / / / | |
| 705 | + * o-o o-o | |
| 706 | + * ,---' | |
| 707 | + * o-o o-o | |
| 708 | + * / / / | |
| 709 | + * o-o o-o | |
| 710 | + */ | |
| 707 | 711 | |
| 708 | 712 | /* Scan8 organization: |
| 709 | 713 | * 0 1 2 3 4 5 6 7 |
| @@ -728,156 +732,173 @@ o-o o-o · 18 unmodified lines | ||
| 728 | 732 | #define LUMA_DC_BLOCK_INDEX 48 |
| 729 | 733 | #define CHROMA_DC_BLOCK_INDEX 49 |
| 730 | 734 | |
| 731 | −//This table must be here because scan8[constant] must be known at compiletime | |
| 732 | −static const uint8_t scan8[16*3 + 3]={ | |
| 733 | − 4+ 1*8, 5+ 1*8, 4+ 2*8, 5+ 2*8, | |
| 734 | − 6+ 1*8, 7+ 1*8, 6+ 2*8, 7+ 2*8, | |
| 735 | − 4+ 3*8, 5+ 3*8, 4+ 4*8, 5+ 4*8, | |
| 736 | − 6+ 3*8, 7+ 3*8, 6+ 4*8, 7+ 4*8, | |
| 737 | − 4+ 6*8, 5+ 6*8, 4+ 7*8, 5+ 7*8, | |
| 738 | − 6+ 6*8, 7+ 6*8, 6+ 7*8, 7+ 7*8, | |
| 739 | − 4+ 8*8, 5+ 8*8, 4+ 9*8, 5+ 9*8, | |
| 740 | − 6+ 8*8, 7+ 8*8, 6+ 9*8, 7+ 9*8, | |
| 741 | − 4+11*8, 5+11*8, 4+12*8, 5+12*8, | |
| 742 | − 6+11*8, 7+11*8, 6+12*8, 7+12*8, | |
| 743 | − 4+13*8, 5+13*8, 4+14*8, 5+14*8, | |
| 744 | − 6+13*8, 7+13*8, 6+14*8, 7+14*8, | |
| 745 | − 0+ 0*8, 0+ 5*8, 0+10*8 | |
| 735 | +// This table must be here because scan8[constant] must be known at compiletime | |
| 736 | +static const uint8_t scan8[16 * 3 + 3] = { | |
| 737 | + 4 + 1 * 8, 5 + 1 * 8, 4 + 2 * 8, 5 + 2 * 8, | |
| 738 | + 6 + 1 * 8, 7 + 1 * 8, 6 + 2 * 8, 7 + 2 * 8, | |
| 739 | + 4 + 3 * 8, 5 + 3 * 8, 4 + 4 * 8, 5 + 4 * 8, | |
| 740 | + 6 + 3 * 8, 7 + 3 * 8, 6 + 4 * 8, 7 + 4 * 8, | |
| 741 | + 4 + 6 * 8, 5 + 6 * 8, 4 + 7 * 8, 5 + 7 * 8, | |
| 742 | + 6 + 6 * 8, 7 + 6 * 8, 6 + 7 * 8, 7 + 7 * 8, | |
| 743 | + 4 + 8 * 8, 5 + 8 * 8, 4 + 9 * 8, 5 + 9 * 8, | |
| 744 | + 6 + 8 * 8, 7 + 8 * 8, 6 + 9 * 8, 7 + 9 * 8, | |
| 745 | + 4 + 11 * 8, 5 + 11 * 8, 4 + 12 * 8, 5 + 12 * 8, | |
| 746 | + 6 + 11 * 8, 7 + 11 * 8, 6 + 12 * 8, 7 + 12 * 8, | |
| 747 | + 4 + 13 * 8, 5 + 13 * 8, 4 + 14 * 8, 5 + 14 * 8, | |
| 748 | + 6 + 13 * 8, 7 + 13 * 8, 6 + 14 * 8, 7 + 14 * 8, | |
| 749 | + 0 + 0 * 8, 0 + 5 * 8, 0 + 10 * 8 | |
| 746 | 750 | }; |
| 747 | 751 | |
| 748 | −static av_always_inline uint32_t pack16to32(int a, int b){ | |
| 752 | +static av_always_inline uint32_t pack16to32(int a, int b) | |
| 753 | +{ | |
| 749 | 754 | #if HAVE_BIGENDIAN |
| 750 | − return (b&0xFFFF) + (a<<16); | |
| 755 | + return (b & 0xFFFF) + (a << 16); | |
| 751 | 756 | #else |
| 752 | − return (a&0xFFFF) + (b<<16); | |
| 757 | + return (a & 0xFFFF) + (b << 16); | |
| 753 | 758 | #endif |
| 754 | 759 | } |
| 755 | 760 | |
| 756 | −static av_always_inline uint16_t pack8to16(int a, int b){ | |
| 761 | +static av_always_inline uint16_t pack8to16(int a, int b) | |
| 762 | +{ | |
| 757 | 763 | #if HAVE_BIGENDIAN |
| 758 | − return (b&0xFF) + (a<<8); | |
| 764 | + return (b & 0xFF) + (a << 8); | |
| 759 | 765 | #else |
| 760 | − return (a&0xFF) + (b<<8); | |
| 766 | + return (a & 0xFF) + (b << 8); | |
| 761 | 767 | #endif |
| 762 | 768 | } |
| 763 | 769 | |
| 764 | 770 | /** |
| 765 | 771 | * Get the chroma qp. |
| 766 | 772 | */ |
| 767 | −static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale){ | |
| 773 | +static av_always_inline int get_chroma_qp(H264Context *h, int t, int qscale) | |
| 774 | +{ | |
| 768 | 775 | return h->pps.chroma_qp_table[t][qscale]; |
| 769 | 776 | } |
| 770 | 777 | |
| 771 | 778 | /** |
| 772 | 779 | * Get the predicted intra4x4 prediction mode. |
| 773 | 780 | */ |
| 774 | −static av_always_inline int pred_intra_mode(H264Context *h, int n){ | |
| 775 | − const int index8= scan8[n]; | |
| 776 | − const int left= h->intra4x4_pred_mode_cache[index8 - 1]; | |
| 777 | − const int top = h->intra4x4_pred_mode_cache[index8 - 8]; | |
| 778 | − const int min= FFMIN(left, top); | |
| 781 | +static av_always_inline int pred_intra_mode(H264Context *h, int n) | |
| 782 | +{ | |
| 783 | + const int index8 = scan8[n]; | |
| 784 | + const int left = h->intra4x4_pred_mode_cache[index8 - 1]; | |
| 785 | + const int top = h->intra4x4_pred_mode_cache[index8 - 8]; | |
| 786 | + const int min = FFMIN(left, top); | |
| 779 | 787 | |
| 780 | − tprintf(h->s.avctx, "mode:%d %d min:%d\n", left ,top, min); | |
| 788 | + tprintf(h->s.avctx, "mode:%d %d min:%d\n", left, top, min); | |
| 781 | 789 | |
| 782 | − if(min<0) return DC_PRED; | |
| 783 | − else return min; | |
| 790 | + if (min < 0) | |
| 791 | + return DC_PRED; | |
| 792 | + else | |
| 793 | + return min; | |
| 784 | 794 | } |
| 785 | 795 | |
| 786 | −static av_always_inline void write_back_intra_pred_mode(H264Context *h){ | |
| 787 | − int8_t *i4x4= h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; | |
| 788 | − int8_t *i4x4_cache= h->intra4x4_pred_mode_cache; | |
| 796 | +static av_always_inline void write_back_intra_pred_mode(H264Context *h) | |
| 797 | +{ | |
| 798 | + int8_t *i4x4 = h->intra4x4_pred_mode + h->mb2br_xy[h->mb_xy]; | |
| 799 | + int8_t *i4x4_cache = h->intra4x4_pred_mode_cache; | |
| 789 | 800 | |
| 790 | − AV_COPY32(i4x4, i4x4_cache + 4 + 8*4); | |
| 791 | − i4x4[4]= i4x4_cache[7+8*3]; | |
| 792 | − i4x4[5]= i4x4_cache[7+8*2]; | |
| 793 | − i4x4[6]= i4x4_cache[7+8*1]; | |
| 801 | + AV_COPY32(i4x4, i4x4_cache + 4 + 8 * 4); | |
| 802 | + i4x4[4] = i4x4_cache[7 + 8 * 3]; | |
| 803 | + i4x4[5] = i4x4_cache[7 + 8 * 2]; | |
| 804 | + i4x4[6] = i4x4_cache[7 + 8 * 1]; | |
| 794 | 805 | } |
| 795 | 806 | |
| 796 | −static av_always_inline void write_back_non_zero_count(H264Context *h){ | |
| 797 | − const int mb_xy= h->mb_xy; | |
| 798 | − uint8_t *nnz = h->non_zero_count[mb_xy]; | |
| 807 | +static av_always_inline void write_back_non_zero_count(H264Context *h) | |
| 808 | +{ | |
| 809 | + const int mb_xy = h->mb_xy; | |
| 810 | + uint8_t *nnz = h->non_zero_count[mb_xy]; | |
| 799 | 811 | uint8_t *nnz_cache = h->non_zero_count_cache; |
| 800 | 812 | |
| 801 | − AV_COPY32(&nnz[ 0], &nnz_cache[4+8* 1]); | |
| 802 | − AV_COPY32(&nnz[ 4], &nnz_cache[4+8* 2]); | |
| 803 | − AV_COPY32(&nnz[ 8], &nnz_cache[4+8* 3]); | |
| 804 | − AV_COPY32(&nnz[12], &nnz_cache[4+8* 4]); | |
| 805 | − AV_COPY32(&nnz[16], &nnz_cache[4+8* 6]); | |
| 806 | − AV_COPY32(&nnz[20], &nnz_cache[4+8* 7]); | |
| 807 | − AV_COPY32(&nnz[32], &nnz_cache[4+8*11]); | |
| 808 | − AV_COPY32(&nnz[36], &nnz_cache[4+8*12]); | |
| 809 | − | |
| 810 | − if(!h->s.chroma_y_shift){ | |
| 811 | − AV_COPY32(&nnz[24], &nnz_cache[4+8* 8]); | |
| 812 | − AV_COPY32(&nnz[28], &nnz_cache[4+8* 9]); | |
| 813 | − AV_COPY32(&nnz[40], &nnz_cache[4+8*13]); | |
| 814 | − AV_COPY32(&nnz[44], &nnz_cache[4+8*14]); | |
| 813 | + AV_COPY32(&nnz[ 0], &nnz_cache[4 + 8 * 1]); | |
| 814 | + AV_COPY32(&nnz[ 4], &nnz_cache[4 + 8 * 2]); | |
| 815 | + AV_COPY32(&nnz[ 8], &nnz_cache[4 + 8 * 3]); | |
| 816 | + AV_COPY32(&nnz[12], &nnz_cache[4 + 8 * 4]); | |
| 817 | + AV_COPY32(&nnz[16], &nnz_cache[4 + 8 * 6]); | |
| 818 | + AV_COPY32(&nnz[20], &nnz_cache[4 + 8 * 7]); | |
| 819 | + AV_COPY32(&nnz[32], &nnz_cache[4 + 8 * 11]); | |
| 820 | + AV_COPY32(&nnz[36], &nnz_cache[4 + 8 * 12]); | |
| 821 | + | |
| 822 | + if (!h->s.chroma_y_shift) { | |
| 823 | + AV_COPY32(&nnz[24], &nnz_cache[4 + 8 * 8]); | |
| 824 | + AV_COPY32(&nnz[28], &nnz_cache[4 + 8 * 9]); | |
| 825 | + AV_COPY32(&nnz[40], &nnz_cache[4 + 8 * 13]); | |
| 826 | + AV_COPY32(&nnz[44], &nnz_cache[4 + 8 * 14]); | |
| 815 | 827 | } |
| 816 | 828 | } |
| 817 | 829 | |
| 818 | −static av_always_inline void write_back_motion_list(H264Context *h, MpegEncContext * const s, int b_stride, | |
| 819 | − int b_xy, int b8_xy, int mb_type, int list ) | |
| 830 | +static av_always_inline void write_back_motion_list(H264Context *h, | |
| 831 | + MpegEncContext *const s, | |
| 832 | + int b_stride, | |
| 833 | + int b_xy, int b8_xy, | |
| 834 | + int mb_type, int list) | |
| 820 | 835 | { |
| 821 | − int16_t (*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; | |
| 822 | − int16_t (*mv_src)[2] = &h->mv_cache[list][scan8[0]]; | |
| 823 | − AV_COPY128(mv_dst + 0*b_stride, mv_src + 8*0); | |
| 824 | − AV_COPY128(mv_dst + 1*b_stride, mv_src + 8*1); | |
| 825 | − AV_COPY128(mv_dst + 2*b_stride, mv_src + 8*2); | |
| 826 | − AV_COPY128(mv_dst + 3*b_stride, mv_src + 8*3); | |
| 827 | − if( CABAC ) { | |
| 828 | − uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8*h->mb_xy : h->mb2br_xy[h->mb_xy]]; | |
| 829 | − uint8_t (*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 830 | − if(IS_SKIP(mb_type)) | |
| 836 | + int16_t(*mv_dst)[2] = &s->current_picture.f.motion_val[list][b_xy]; | |
| 837 | + int16_t(*mv_src)[2] = &h->mv_cache[list][scan8[0]]; | |
| 838 | + AV_COPY128(mv_dst + 0 * b_stride, mv_src + 8 * 0); | |
| 839 | + AV_COPY128(mv_dst + 1 * b_stride, mv_src + 8 * 1); | |
| 840 | + AV_COPY128(mv_dst + 2 * b_stride, mv_src + 8 * 2); | |
| 841 | + AV_COPY128(mv_dst + 3 * b_stride, mv_src + 8 * 3); | |
| 842 | + if (CABAC) { | |
| 843 | + uint8_t (*mvd_dst)[2] = &h->mvd_table[list][FMO ? 8 * h->mb_xy | |
| 844 | + : h->mb2br_xy[h->mb_xy]]; | |
| 845 | + uint8_t(*mvd_src)[2] = &h->mvd_cache[list][scan8[0]]; | |
| 846 | + if (IS_SKIP(mb_type)) { | |
| 831 | 847 | AV_ZERO128(mvd_dst); |
| 832 | − else{ | |
| 833 | − AV_COPY64(mvd_dst, mvd_src + 8*3); | |
| 834 | − AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8*0); | |
| 835 | − AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8*1); | |
| 836 | − AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8*2); | |
| 848 | + } else { | |
| 849 | + AV_COPY64(mvd_dst, mvd_src + 8 * 3); | |
| 850 | + AV_COPY16(mvd_dst + 3 + 3, mvd_src + 3 + 8 * 0); | |
| 851 | + AV_COPY16(mvd_dst + 3 + 2, mvd_src + 3 + 8 * 1); | |
| 852 | + AV_COPY16(mvd_dst + 3 + 1, mvd_src + 3 + 8 * 2); | |
| 837 | 853 | } |
| 838 | 854 | } |
| 839 | 855 | |
| 840 | 856 | { |
| 841 | 857 | int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy]; |
| 842 | 858 | int8_t *ref_cache = h->ref_cache[list]; |
| 843 | − ref_index[0+0*2]= ref_cache[scan8[0]]; | |
| 844 | − ref_index[1+0*2]= ref_cache[scan8[4]]; | |
| 845 | − ref_index[0+1*2]= ref_cache[scan8[8]]; | |
| 846 | − ref_index[1+1*2]= ref_cache[scan8[12]]; | |
| 859 | + ref_index[0 + 0 * 2] = ref_cache[scan8[0]]; | |
| 860 | + ref_index[1 + 0 * 2] = ref_cache[scan8[4]]; | |
| 861 | + ref_index[0 + 1 * 2] = ref_cache[scan8[8]]; | |
| 862 | + ref_index[1 + 1 * 2] = ref_cache[scan8[12]]; | |
| 847 | 863 | } |
| 848 | 864 | } |
| 849 | 865 | |
| 850 | −static av_always_inline void write_back_motion(H264Context *h, int mb_type){ | |
| 851 | − MpegEncContext * const s = &h->s; | |
| 852 | − const int b_stride = h->b_stride; | |
| 853 | − const int b_xy = 4*s->mb_x + 4*s->mb_y*h->b_stride; //try mb2b(8)_xy | |
| 854 | − const int b8_xy= 4*h->mb_xy; | |
| 866 | +static av_always_inline void write_back_motion(H264Context *h, int mb_type) | |
| 867 | +{ | |
| 868 | + MpegEncContext *const s = &h->s; | |
| 869 | + const int b_stride = h->b_stride; | |
| 870 | + const int b_xy = 4 * s->mb_x + 4 * s->mb_y * h->b_stride; // try mb2b(8)_xy | |
| 871 | + const int b8_xy = 4 * h->mb_xy; | |
| 855 | 872 | |
| 856 | − if(USES_LIST(mb_type, 0)){ | |
| 873 | + if (USES_LIST(mb_type, 0)) { | |
| 857 | 874 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0); |
| 858 | − }else{ | |
| 875 | + } else { | |
| 859 | 876 | fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy], |
| 860 | 877 | 2, 2, 2, (uint8_t)LIST_NOT_USED, 1); |
| 861 | 878 | } |
| 862 | − if(USES_LIST(mb_type, 1)){ | |
| 879 | + if (USES_LIST(mb_type, 1)) | |
| 863 | 880 | write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1); |
| 864 | − } | |
| 865 | 881 | |
| 866 | − if(h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC){ | |
| 867 | − if(IS_8X8(mb_type)){ | |
| 868 | − uint8_t *direct_table = &h->direct_table[4*h->mb_xy]; | |
| 869 | − direct_table[1] = h->sub_mb_type[1]>>1; | |
| 870 | − direct_table[2] = h->sub_mb_type[2]>>1; | |
| 871 | − direct_table[3] = h->sub_mb_type[3]>>1; | |
| 882 | + if (h->slice_type_nos == AV_PICTURE_TYPE_B && CABAC) { | |
| 883 | + if (IS_8X8(mb_type)) { | |
| 884 | + uint8_t *direct_table = &h->direct_table[4 * h->mb_xy]; | |
| 885 | + direct_table[1] = h->sub_mb_type[1] >> 1; | |
| 886 | + direct_table[2] = h->sub_mb_type[2] >> 1; | |
| 887 | + direct_table[3] = h->sub_mb_type[3] >> 1; | |
| 872 | 888 | } |
| 873 | 889 | } |
| 874 | 890 | } |
| 875 | 891 | |
| 876 | −static av_always_inline int get_dct8x8_allowed(H264Context *h){ | |
| 877 | − if(h->sps.direct_8x8_inference_flag) | |
| 878 | − return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8 )*0x0001000100010001ULL)); | |
| 892 | +static av_always_inline int get_dct8x8_allowed(H264Context *h) | |
| 893 | +{ | |
| 894 | + if (h->sps.direct_8x8_inference_flag) | |
| 895 | + return !(AV_RN64A(h->sub_mb_type) & | |
| 896 | + ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8) * | |
| 897 | + 0x0001000100010001ULL)); | |
| 879 | 898 | else |
| 880 | − return !(AV_RN64A(h->sub_mb_type) & ((MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8|MB_TYPE_DIRECT2)*0x0001000100010001ULL)); | |
| 899 | + return !(AV_RN64A(h->sub_mb_type) & | |
| 900 | + ((MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_DIRECT2) * | |
| 901 | + 0x0001000100010001ULL)); | |
| 881 | 902 | } |
| 882 | 903 | |
| 883 | 904 | #endif /* AVCODEC_H264_H */ |
| @@ -30,240 +30,243 @@ · 29 unmodified lines | ||
| 30 | 30 | #define AVCODEC_H264DATA_H |
| 31 | 31 | |
| 32 | 32 | #include <stdint.h> |
| 33 | + | |
| 33 | 34 | #include "libavutil/rational.h" |
| 34 | 35 | #include "mpegvideo.h" |
| 35 | 36 | #include "h264.h" |
| 36 | 37 | |
| 38 | +static const uint8_t golomb_to_pict_type[5] = { | |
| 39 | + AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I, | |
| 40 | + AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI | |
| 41 | +}; | |
| 37 | 42 | |
| 38 | −static const uint8_t golomb_to_pict_type[5]= | |
| 39 | −{AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_SP, AV_PICTURE_TYPE_SI}; | |
| 40 | − | |
| 41 | −static const uint8_t golomb_to_intra4x4_cbp[48]={ | |
| 42 | − 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, | |
| 43 | − 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, | |
| 44 | − 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 | |
| 43 | +static const uint8_t golomb_to_intra4x4_cbp[48] = { | |
| 44 | + 47, 31, 15, 0, 23, 27, 29, 30, 7, 11, 13, 14, 39, 43, 45, 46, | |
| 45 | + 16, 3, 5, 10, 12, 19, 21, 26, 28, 35, 37, 42, 44, 1, 2, 4, | |
| 46 | + 8, 17, 18, 20, 24, 6, 9, 22, 25, 32, 33, 34, 36, 40, 38, 41 | |
| 45 | 47 | }; |
| 46 | 48 | |
| 47 | −static const uint8_t golomb_to_inter_cbp[48]={ | |
| 48 | − 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, | |
| 49 | − 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, | |
| 50 | − 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 | |
| 49 | +static const uint8_t golomb_to_inter_cbp[48] = { | |
| 50 | + 0, 16, 1, 2, 4, 8, 32, 3, 5, 10, 12, 15, 47, 7, 11, 13, | |
| 51 | + 14, 6, 9, 31, 35, 37, 42, 44, 33, 34, 36, 40, 39, 43, 45, 46, | |
| 52 | + 17, 18, 20, 24, 19, 21, 26, 28, 23, 27, 29, 30, 22, 25, 38, 41 | |
| 51 | 53 | }; |
| 52 | 54 | |
| 53 | −static const uint8_t zigzag_scan[16]={ | |
| 54 | − 0+0*4, 1+0*4, 0+1*4, 0+2*4, | |
| 55 | − 1+1*4, 2+0*4, 3+0*4, 2+1*4, | |
| 56 | − 1+2*4, 0+3*4, 1+3*4, 2+2*4, | |
| 57 | − 3+1*4, 3+2*4, 2+3*4, 3+3*4, | |
| 55 | +static const uint8_t zigzag_scan[16] = { | |
| 56 | + 0 + 0 * 4, 1 + 0 * 4, 0 + 1 * 4, 0 + 2 * 4, | |
| 57 | + 1 + 1 * 4, 2 + 0 * 4, 3 + 0 * 4, 2 + 1 * 4, | |
| 58 | + 1 + 2 * 4, 0 + 3 * 4, 1 + 3 * 4, 2 + 2 * 4, | |
| 59 | + 3 + 1 * 4, 3 + 2 * 4, 2 + 3 * 4, 3 + 3 * 4, | |
| 58 | 60 | }; |
| 59 | 61 | |
| 60 | −static const uint8_t field_scan[16]={ | |
| 61 | − 0+0*4, 0+1*4, 1+0*4, 0+2*4, | |
| 62 | − 0+3*4, 1+1*4, 1+2*4, 1+3*4, | |
| 63 | − 2+0*4, 2+1*4, 2+2*4, 2+3*4, | |
| 64 | − 3+0*4, 3+1*4, 3+2*4, 3+3*4, | |
| 62 | +static const uint8_t field_scan[16] = { | |
| 63 | + 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4, | |
| 64 | + 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4, | |
| 65 | + 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4, | |
| 66 | + 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4, | |
| 65 | 67 | }; |
| 66 | 68 | |
| 67 | −static const uint8_t luma_dc_zigzag_scan[16]={ | |
| 68 | − 0*16 + 0*64, 1*16 + 0*64, 2*16 + 0*64, 0*16 + 2*64, | |
| 69 | − 3*16 + 0*64, 0*16 + 1*64, 1*16 + 1*64, 2*16 + 1*64, | |
| 70 | − 1*16 + 2*64, 2*16 + 2*64, 3*16 + 2*64, 0*16 + 3*64, | |
| 71 | − 3*16 + 1*64, 1*16 + 3*64, 2*16 + 3*64, 3*16 + 3*64, | |
| 69 | +static const uint8_t luma_dc_zigzag_scan[16] = { | |
| 70 | + 0 * 16 + 0 * 64, 1 * 16 + 0 * 64, 2 * 16 + 0 * 64, 0 * 16 + 2 * 64, | |
| 71 | + 3 * 16 + 0 * 64, 0 * 16 + 1 * 64, 1 * 16 + 1 * 64, 2 * 16 + 1 * 64, | |
| 72 | + 1 * 16 + 2 * 64, 2 * 16 + 2 * 64, 3 * 16 + 2 * 64, 0 * 16 + 3 * 64, | |
| 73 | + 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 2 * 16 + 3 * 64, 3 * 16 + 3 * 64, | |
| 72 | 74 | }; |
| 73 | 75 | |
| 74 | −static const uint8_t luma_dc_field_scan[16]={ | |
| 75 | − 0*16 + 0*64, 2*16 + 0*64, 1*16 + 0*64, 0*16 + 2*64, | |
| 76 | − 2*16 + 2*64, 3*16 + 0*64, 1*16 + 2*64, 3*16 + 2*64, | |
| 77 | − 0*16 + 1*64, 2*16 + 1*64, 0*16 + 3*64, 2*16 + 3*64, | |
| 78 | − 1*16 + 1*64, 3*16 + 1*64, 1*16 + 3*64, 3*16 + 3*64, | |
| 76 | +static const uint8_t luma_dc_field_scan[16] = { | |
| 77 | + 0 * 16 + 0 * 64, 2 * 16 + 0 * 64, 1 * 16 + 0 * 64, 0 * 16 + 2 * 64, | |
| 78 | + 2 * 16 + 2 * 64, 3 * 16 + 0 * 64, 1 * 16 + 2 * 64, 3 * 16 + 2 * 64, | |
| 79 | + 0 * 16 + 1 * 64, 2 * 16 + 1 * 64, 0 * 16 + 3 * 64, 2 * 16 + 3 * 64, | |
| 80 | + 1 * 16 + 1 * 64, 3 * 16 + 1 * 64, 1 * 16 + 3 * 64, 3 * 16 + 3 * 64, | |
| 79 | 81 | }; |
| 80 | 82 | |
| 81 | −static const uint8_t chroma_dc_scan[4]={ | |
| 82 | − (0+0*2)*16, (1+0*2)*16, | |
| 83 | − (0+1*2)*16, (1+1*2)*16, | |
| 83 | +static const uint8_t chroma_dc_scan[4] = { | |
| 84 | + (0 + 0 * 2) * 16, (1 + 0 * 2) * 16, | |
| 85 | + (0 + 1 * 2) * 16, (1 + 1 * 2) * 16, | |
| 84 | 86 | }; |
| 85 | 87 | |
| 86 | −static const uint8_t chroma422_dc_scan[8]={ | |
| 87 | − (0+0*2)*16, (0+1*2)*16, | |
| 88 | − (1+0*2)*16, (0+2*2)*16, | |
| 89 | − (0+3*2)*16, (1+1*2)*16, | |
| 90 | − (1+2*2)*16, (1+3*2)*16, | |
| 88 | +static const uint8_t chroma422_dc_scan[8] = { | |
| 89 | + (0 + 0 * 2) * 16, (0 + 1 * 2) * 16, | |
| 90 | + (1 + 0 * 2) * 16, (0 + 2 * 2) * 16, | |
| 91 | + (0 + 3 * 2) * 16, (1 + 1 * 2) * 16, | |
| 92 | + (1 + 2 * 2) * 16, (1 + 3 * 2) * 16, | |
| 91 | 93 | }; |
| 92 | 94 | |
| 93 | 95 | // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)] |
| 94 | −static const uint8_t zigzag_scan8x8_cavlc[64]={ | |
| 95 | − 0+0*8, 1+1*8, 1+2*8, 2+2*8, | |
| 96 | − 4+1*8, 0+5*8, 3+3*8, 7+0*8, | |
| 97 | − 3+4*8, 1+7*8, 5+3*8, 6+3*8, | |
| 98 | − 2+7*8, 6+4*8, 5+6*8, 7+5*8, | |
| 99 | − 1+0*8, 2+0*8, 0+3*8, 3+1*8, | |
| 100 | − 3+2*8, 0+6*8, 4+2*8, 6+1*8, | |
| 101 | − 2+5*8, 2+6*8, 6+2*8, 5+4*8, | |
| 102 | − 3+7*8, 7+3*8, 4+7*8, 7+6*8, | |
| 103 | − 0+1*8, 3+0*8, 0+4*8, 4+0*8, | |
| 104 | − 2+3*8, 1+5*8, 5+1*8, 5+2*8, | |
| 105 | − 1+6*8, 3+5*8, 7+1*8, 4+5*8, | |
| 106 | − 4+6*8, 7+4*8, 5+7*8, 6+7*8, | |
| 107 | − 0+2*8, 2+1*8, 1+3*8, 5+0*8, | |
| 108 | − 1+4*8, 2+4*8, 6+0*8, 4+3*8, | |
| 109 | − 0+7*8, 4+4*8, 7+2*8, 3+6*8, | |
| 110 | − 5+5*8, 6+5*8, 6+6*8, 7+7*8, | |
| 96 | +static const uint8_t zigzag_scan8x8_cavlc[64] = { | |
| 97 | + 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8, | |
| 98 | + 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8, | |
| 99 | + 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8, | |
| 100 | + 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8, | |
| 101 | + 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8, | |
| 102 | + 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8, | |
| 103 | + 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8, | |
| 104 | + 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8, | |
| 105 | + 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8, | |
| 106 | + 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8, | |
| 107 | + 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8, | |
| 108 | + 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8, | |
| 109 | + 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8, | |
| 110 | + 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8, | |
| 111 | + 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8, | |
| 112 | + 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8, | |
| 111 | 113 | }; |
| 112 | 114 | |
| 113 | −static const uint8_t field_scan8x8[64]={ | |
| 114 | − 0+0*8, 0+1*8, 0+2*8, 1+0*8, | |
| 115 | − 1+1*8, 0+3*8, 0+4*8, 1+2*8, | |
| 116 | − 2+0*8, 1+3*8, 0+5*8, 0+6*8, | |
| 117 | − 0+7*8, 1+4*8, 2+1*8, 3+0*8, | |
| 118 | − 2+2*8, 1+5*8, 1+6*8, 1+7*8, | |
| 119 | − 2+3*8, 3+1*8, 4+0*8, 3+2*8, | |
| 120 | − 2+4*8, 2+5*8, 2+6*8, 2+7*8, | |
| 121 | − 3+3*8, 4+1*8, 5+0*8, 4+2*8, | |
| 122 | − 3+4*8, 3+5*8, 3+6*8, 3+7*8, | |
| 123 | − 4+3*8, 5+1*8, 6+0*8, 5+2*8, | |
| 124 | − 4+4*8, 4+5*8, 4+6*8, 4+7*8, | |
| 125 | − 5+3*8, 6+1*8, 6+2*8, 5+4*8, | |
| 126 | − 5+5*8, 5+6*8, 5+7*8, 6+3*8, | |
| 127 | − 7+0*8, 7+1*8, 6+4*8, 6+5*8, | |
| 128 | − 6+6*8, 6+7*8, 7+2*8, 7+3*8, | |
| 129 | − 7+4*8, 7+5*8, 7+6*8, 7+7*8, | |
| 115 | +static const uint8_t field_scan8x8[64] = { | |
| 116 | + 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8, | |
| 117 | + 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8, | |
| 118 | + 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8, | |
| 119 | + 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8, | |
| 120 | + 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8, | |
| 121 | + 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8, | |
| 122 | + 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8, | |
| 123 | + 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8, | |
| 124 | + 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8, | |
| 125 | + 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8, | |
| 126 | + 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8, | |
| 127 | + 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8, | |
| 128 | + 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8, | |
| 129 | + 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8, | |
| 130 | + 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8, | |
| 131 | + 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8, | |
| 130 | 132 | }; |
| 131 | 133 | |
| 132 | −static const uint8_t field_scan8x8_cavlc[64]={ | |
| 133 | − 0+0*8, 1+1*8, 2+0*8, 0+7*8, | |
| 134 | − 2+2*8, 2+3*8, 2+4*8, 3+3*8, | |
| 135 | − 3+4*8, 4+3*8, 4+4*8, 5+3*8, | |
| 136 | − 5+5*8, 7+0*8, 6+6*8, 7+4*8, | |
| 137 | − 0+1*8, 0+3*8, 1+3*8, 1+4*8, | |
| 138 | − 1+5*8, 3+1*8, 2+5*8, 4+1*8, | |
| 139 | − 3+5*8, 5+1*8, 4+5*8, 6+1*8, | |
| 140 | − 5+6*8, 7+1*8, 6+7*8, 7+5*8, | |
| 141 | − 0+2*8, 0+4*8, 0+5*8, 2+1*8, | |
| 142 | − 1+6*8, 4+0*8, 2+6*8, 5+0*8, | |
| 143 | − 3+6*8, 6+0*8, 4+6*8, 6+2*8, | |
| 144 | − 5+7*8, 6+4*8, 7+2*8, 7+6*8, | |
| 145 | − 1+0*8, 1+2*8, 0+6*8, 3+0*8, | |
| 146 | − 1+7*8, 3+2*8, 2+7*8, 4+2*8, | |
| 147 | − 3+7*8, 5+2*8, 4+7*8, 5+4*8, | |
| 148 | − 6+3*8, 6+5*8, 7+3*8, 7+7*8, | |
| 134 | +static const uint8_t field_scan8x8_cavlc[64] = { | |
| 135 | + 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8, | |
| 136 | + 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8, | |
| 137 | + 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8, | |
| 138 | + 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8, | |
| 139 | + 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8, | |
| 140 | + 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8, | |
| 141 | + 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8, | |
| 142 | + 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8, | |
| 143 | + 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8, | |
| 144 | + 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8, | |
| 145 | + 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8, | |
| 146 | + 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8, | |
| 147 | + 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8, | |
| 148 | + 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8, | |
| 149 | + 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8, | |
| 150 | + 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8, | |
| 149 | 151 | }; |
| 150 | 152 | |
| 151 | −typedef struct IMbInfo{ | |
| 153 | +typedef struct IMbInfo { | |
| 152 | 154 | uint16_t type; |
| 153 | 155 | uint8_t pred_mode; |
| 154 | 156 | uint8_t cbp; |
| 155 | 157 | } IMbInfo; |
| 156 | 158 | |
| 157 | −static const IMbInfo i_mb_type_info[26]={ | |
| 158 | −{MB_TYPE_INTRA4x4 , -1, -1}, | |
| 159 | −{MB_TYPE_INTRA16x16, 2, 0}, | |
| 160 | −{MB_TYPE_INTRA16x16, 1, 0}, | |
| 161 | −{MB_TYPE_INTRA16x16, 0, 0}, | |
| 162 | −{MB_TYPE_INTRA16x16, 3, 0}, | |
| 163 | −{MB_TYPE_INTRA16x16, 2, 16}, | |
| 164 | −{MB_TYPE_INTRA16x16, 1, 16}, | |
| 165 | −{MB_TYPE_INTRA16x16, 0, 16}, | |
| 166 | −{MB_TYPE_INTRA16x16, 3, 16}, | |
| 167 | −{MB_TYPE_INTRA16x16, 2, 32}, | |
| 168 | −{MB_TYPE_INTRA16x16, 1, 32}, | |
| 169 | −{MB_TYPE_INTRA16x16, 0, 32}, | |
| 170 | −{MB_TYPE_INTRA16x16, 3, 32}, | |
| 171 | −{MB_TYPE_INTRA16x16, 2, 15+0}, | |
| 172 | −{MB_TYPE_INTRA16x16, 1, 15+0}, | |
| 173 | −{MB_TYPE_INTRA16x16, 0, 15+0}, | |
| 174 | −{MB_TYPE_INTRA16x16, 3, 15+0}, | |
| 175 | −{MB_TYPE_INTRA16x16, 2, 15+16}, | |
| 176 | −{MB_TYPE_INTRA16x16, 1, 15+16}, | |
| 177 | −{MB_TYPE_INTRA16x16, 0, 15+16}, | |
| 178 | −{MB_TYPE_INTRA16x16, 3, 15+16}, | |
| 179 | −{MB_TYPE_INTRA16x16, 2, 15+32}, | |
| 180 | −{MB_TYPE_INTRA16x16, 1, 15+32}, | |
| 181 | −{MB_TYPE_INTRA16x16, 0, 15+32}, | |
| 182 | −{MB_TYPE_INTRA16x16, 3, 15+32}, | |
| 183 | −{MB_TYPE_INTRA_PCM , -1, -1}, | |
| 159 | +static const IMbInfo i_mb_type_info[26] = { | |
| 160 | + { MB_TYPE_INTRA4x4, -1, -1 }, | |
| 161 | + { MB_TYPE_INTRA16x16, 2, 0 }, | |
| 162 | + { MB_TYPE_INTRA16x16, 1, 0 }, | |
| 163 | + { MB_TYPE_INTRA16x16, 0, 0 }, | |
| 164 | + { MB_TYPE_INTRA16x16, 3, 0 }, | |
| 165 | + { MB_TYPE_INTRA16x16, 2, 16 }, | |
| 166 | + { MB_TYPE_INTRA16x16, 1, 16 }, | |
| 167 | + { MB_TYPE_INTRA16x16, 0, 16 }, | |
| 168 | + { MB_TYPE_INTRA16x16, 3, 16 }, | |
| 169 | + { MB_TYPE_INTRA16x16, 2, 32 }, | |
| 170 | + { MB_TYPE_INTRA16x16, 1, 32 }, | |
| 171 | + { MB_TYPE_INTRA16x16, 0, 32 }, | |
| 172 | + { MB_TYPE_INTRA16x16, 3, 32 }, | |
| 173 | + { MB_TYPE_INTRA16x16, 2, 15 + 0 }, | |
| 174 | + { MB_TYPE_INTRA16x16, 1, 15 + 0 }, | |
| 175 | + { MB_TYPE_INTRA16x16, 0, 15 + 0 }, | |
| 176 | + { MB_TYPE_INTRA16x16, 3, 15 + 0 }, | |
| 177 | + { MB_TYPE_INTRA16x16, 2, 15 + 16 }, | |
| 178 | + { MB_TYPE_INTRA16x16, 1, 15 + 16 }, | |
| 179 | + { MB_TYPE_INTRA16x16, 0, 15 + 16 }, | |
| 180 | + { MB_TYPE_INTRA16x16, 3, 15 + 16 }, | |
| 181 | + { MB_TYPE_INTRA16x16, 2, 15 + 32 }, | |
| 182 | + { MB_TYPE_INTRA16x16, 1, 15 + 32 }, | |
| 183 | + { MB_TYPE_INTRA16x16, 0, 15 + 32 }, | |
| 184 | + { MB_TYPE_INTRA16x16, 3, 15 + 32 }, | |
| 185 | + { MB_TYPE_INTRA_PCM, -1, -1 }, | |
| 184 | 186 | }; |
| 185 | 187 | |
| 186 | −typedef struct PMbInfo{ | |
| 188 | +typedef struct PMbInfo { | |
| 187 | 189 | uint16_t type; |
| 188 | 190 | uint8_t partition_count; |
| 189 | 191 | } PMbInfo; |
| 190 | 192 | |
| 191 | −static const PMbInfo p_mb_type_info[5]={ | |
| 192 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | |
| 193 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | |
| 194 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P1L0, 2}, | |
| 195 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0, 4}, | |
| 196 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P1L0|MB_TYPE_REF0, 4}, | |
| 193 | +static const PMbInfo p_mb_type_info[5] = { | |
| 194 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, | |
| 195 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, | |
| 196 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2 }, | |
| 197 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4 }, | |
| 198 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_REF0, 4 }, | |
| 197 | 199 | }; |
| 198 | 200 | |
| 199 | −static const PMbInfo p_sub_mb_type_info[4]={ | |
| 200 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1}, | |
| 201 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 , 2}, | |
| 202 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 , 2}, | |
| 203 | −{MB_TYPE_8x8 |MB_TYPE_P0L0 , 4}, | |
| 201 | +static const PMbInfo p_sub_mb_type_info[4] = { | |
| 202 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1 }, | |
| 203 | + { MB_TYPE_16x8 | MB_TYPE_P0L0, 2 }, | |
| 204 | + { MB_TYPE_8x16 | MB_TYPE_P0L0, 2 }, | |
| 205 | + { MB_TYPE_8x8 | MB_TYPE_P0L0, 4 }, | |
| 204 | 206 | }; |
| 205 | 207 | |
| 206 | −static const PMbInfo b_mb_type_info[23]={ | |
| 207 | −{MB_TYPE_DIRECT2|MB_TYPE_L0L1 , 1, }, | |
| 208 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | |
| 209 | −{MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | |
| 210 | −{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | |
| 211 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 212 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 213 | −{MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 214 | −{MB_TYPE_8x16 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 215 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | |
| 216 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L1, 2, }, | |
| 217 | −{MB_TYPE_16x8 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 218 | −{MB_TYPE_8x16 |MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 219 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 220 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 221 | −{MB_TYPE_16x8 |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 222 | −{MB_TYPE_8x16 |MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 223 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 224 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0 , 2, }, | |
| 225 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 226 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 227 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 228 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 229 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, }, | |
| 208 | +static const PMbInfo b_mb_type_info[23] = { | |
| 209 | + { MB_TYPE_DIRECT2 | MB_TYPE_L0L1, 1, }, | |
| 210 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, | |
| 211 | + { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, | |
| 212 | + { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, | |
| 213 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 214 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 215 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 216 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 217 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, | |
| 218 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L1, 2, }, | |
| 219 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 220 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 221 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 222 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 223 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 224 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 225 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 226 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0, 2, }, | |
| 227 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 228 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 229 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 230 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 231 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, }, | |
| 230 | 232 | }; |
| 231 | 233 | |
| 232 | −static const PMbInfo b_sub_mb_type_info[13]={ | |
| 233 | −{MB_TYPE_DIRECT2 , 1, }, | |
| 234 | −{MB_TYPE_16x16|MB_TYPE_P0L0 , 1, }, | |
| 235 | −{MB_TYPE_16x16 |MB_TYPE_P0L1 , 1, }, | |
| 236 | −{MB_TYPE_16x16|MB_TYPE_P0L0|MB_TYPE_P0L1 , 1, }, | |
| 237 | −{MB_TYPE_16x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 238 | −{MB_TYPE_8x16 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 2, }, | |
| 239 | −{MB_TYPE_16x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 240 | −{MB_TYPE_8x16 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 2, }, | |
| 241 | −{MB_TYPE_16x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 242 | −{MB_TYPE_8x16 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 2, }, | |
| 243 | −{MB_TYPE_8x8 |MB_TYPE_P0L0 |MB_TYPE_P1L0 , 4, }, | |
| 244 | −{MB_TYPE_8x8 |MB_TYPE_P0L1 |MB_TYPE_P1L1, 4, }, | |
| 245 | −{MB_TYPE_8x8 |MB_TYPE_P0L0|MB_TYPE_P0L1|MB_TYPE_P1L0|MB_TYPE_P1L1, 4, }, | |
| 234 | +static const PMbInfo b_sub_mb_type_info[13] = { | |
| 235 | + { MB_TYPE_DIRECT2, 1, }, | |
| 236 | + { MB_TYPE_16x16 | MB_TYPE_P0L0, 1, }, | |
| 237 | + { MB_TYPE_16x16 | MB_TYPE_P0L1, 1, }, | |
| 238 | + { MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1, 1, }, | |
| 239 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 240 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 2, }, | |
| 241 | + { MB_TYPE_16x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 242 | + { MB_TYPE_8x16 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 2, }, | |
| 243 | + { MB_TYPE_16x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 244 | + { MB_TYPE_8x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 2, }, | |
| 245 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P1L0, 4, }, | |
| 246 | + { MB_TYPE_8x8 | MB_TYPE_P0L1 | MB_TYPE_P1L1, 4, }, | |
| 247 | + { MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_P1L0 | MB_TYPE_P1L1, 4, }, | |
| 246 | 248 | }; |
| 247 | 249 | |
| 248 | −static const uint8_t dequant4_coeff_init[6][3]={ | |
| 249 | − {10,13,16}, | |
| 250 | − {11,14,18}, | |
| 251 | − {13,16,20}, | |
| 252 | − {14,18,23}, | |
| 253 | − {16,20,25}, | |
| 254 | − {18,23,29}, | |
| 250 | +static const uint8_t dequant4_coeff_init[6][3] = { | |
| 251 | + { 10, 13, 16 }, | |
| 252 | + { 11, 14, 18 }, | |
| 253 | + { 13, 16, 20 }, | |
| 254 | + { 14, 18, 23 }, | |
| 255 | + { 16, 20, 25 }, | |
| 256 | + { 18, 23, 29 }, | |
| 255 | 257 | }; |
| 256 | 258 | |
| 257 | 259 | static const uint8_t dequant8_coeff_init_scan[16] = { |
| 258 | − 0,3,4,3, 3,1,5,1, 4,5,2,5, 3,1,5,1 | |
| 260 | + 0, 3, 4, 3, 3, 1, 5, 1, 4, 5, 2, 5, 3, 1, 5, 1 | |
| 259 | 261 | }; |
| 260 | −static const uint8_t dequant8_coeff_init[6][6]={ | |
| 261 | − {20,18,32,19,25,24}, | |
| 262 | − {22,19,35,21,28,26}, | |
| 263 | − {26,23,42,24,33,31}, | |
| 264 | − {28,25,45,26,35,33}, | |
| 265 | − {32,28,51,30,40,38}, | |
| 266 | − {36,32,58,34,46,43}, | |
| 262 | + | |
| 263 | +static const uint8_t dequant8_coeff_init[6][6] = { | |
| 264 | + { 20, 18, 32, 19, 25, 24 }, | |
| 265 | + { 22, 19, 35, 21, 28, 26 }, | |
| 266 | + { 26, 23, 42, 24, 33, 31 }, | |
| 267 | + { 28, 25, 45, 26, 35, 33 }, | |
| 268 | + { 32, 28, 51, 30, 40, 38 }, | |
| 269 | + { 36, 32, 58, 34, 46, 43 }, | |
| 267 | 270 | }; |
| 268 | 271 | |
| 269 | 272 | #endif /* AVCODEC_H264DATA_H */ |
| @@ -35,18 +35,18 @@ · 34 unmodified lines | ||
| 35 | 35 | * Prediction types |
| 36 | 36 | */ |
| 37 | 37 | //@{ |
| 38 | −#define VERT_PRED 0 | |
| 39 | −#define HOR_PRED 1 | |
| 40 | −#define DC_PRED 2 | |
| 41 | −#define DIAG_DOWN_LEFT_PRED 3 | |
| 42 | −#define DIAG_DOWN_RIGHT_PRED 4 | |
| 43 | −#define VERT_RIGHT_PRED 5 | |
| 44 | −#define HOR_DOWN_PRED 6 | |
| 45 | −#define VERT_LEFT_PRED 7 | |
| 46 | −#define HOR_UP_PRED 8 | |
| 38 | +#define VERT_PRED 0 | |
| 39 | +#define HOR_PRED 1 | |
| 40 | +#define DC_PRED 2 | |
| 41 | +#define DIAG_DOWN_LEFT_PRED 3 | |
| 42 | +#define DIAG_DOWN_RIGHT_PRED 4 | |
| 43 | +#define VERT_RIGHT_PRED 5 | |
| 44 | +#define HOR_DOWN_PRED 6 | |
| 45 | +#define VERT_LEFT_PRED 7 | |
| 46 | +#define HOR_UP_PRED 8 | |
| 47 | 47 | |
| 48 | 48 | // DC edge (not for VP8) |
| 49 | −#define LEFT_DC_PRED 9 | |
| 49 | +#define LEFT_DC_PRED 9 | |
| 50 | 50 | #define TOP_DC_PRED 10 |
| 51 | 51 | #define DC_128_PRED 11 |
| 52 | 52 | |
| @@ -56,7 +56,7 @@ · 3 unmodified lines | ||
| 56 | 56 | #define VERT_LEFT_PRED_RV40_NODOWN 14 |
| 57 | 57 | |
| 58 | 58 | // VP8 specific |
| 59 | −#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane | |
| 59 | +#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane | |
| 60 | 60 | #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of |
| 61 | 61 | ///< (left col+cur col x2+right col) / 4; |
| 62 | 62 | ///< this is the "unaveraged" one |
| @@ -65,44 +65,53 @@ · 2 unmodified lines | ||
| 65 | 65 | #define DC_127_PRED 12 |
| 66 | 66 | #define DC_129_PRED 13 |
| 67 | 67 | |
| 68 | −#define DC_PRED8x8 0 | |
| 69 | −#define HOR_PRED8x8 1 | |
| 70 | −#define VERT_PRED8x8 2 | |
| 71 | −#define PLANE_PRED8x8 3 | |
| 68 | +#define DC_PRED8x8 0 | |
| 69 | +#define HOR_PRED8x8 1 | |
| 70 | +#define VERT_PRED8x8 2 | |
| 71 | +#define PLANE_PRED8x8 3 | |
| 72 | 72 | |
| 73 | 73 | // DC edge |
| 74 | −#define LEFT_DC_PRED8x8 4 | |
| 75 | −#define TOP_DC_PRED8x8 5 | |
| 76 | −#define DC_128_PRED8x8 6 | |
| 74 | +#define LEFT_DC_PRED8x8 4 | |
| 75 | +#define TOP_DC_PRED8x8 5 | |
| 76 | +#define DC_128_PRED8x8 6 | |
| 77 | 77 | |
| 78 | 78 | // H264/SVQ3 (8x8) specific |
| 79 | −#define ALZHEIMER_DC_L0T_PRED8x8 7 | |
| 80 | −#define ALZHEIMER_DC_0LT_PRED8x8 8 | |
| 81 | −#define ALZHEIMER_DC_L00_PRED8x8 9 | |
| 79 | +#define ALZHEIMER_DC_L0T_PRED8x8 7 | |
| 80 | +#define ALZHEIMER_DC_0LT_PRED8x8 8 | |
| 81 | +#define ALZHEIMER_DC_L00_PRED8x8 9 | |
| 82 | 82 | #define ALZHEIMER_DC_0L0_PRED8x8 10 |
| 83 | 83 | |
| 84 | 84 | // VP8 specific |
| 85 | −#define DC_127_PRED8x8 7 | |
| 86 | −#define DC_129_PRED8x8 8 | |
| 85 | +#define DC_127_PRED8x8 7 | |
| 86 | +#define DC_129_PRED8x8 8 | |
| 87 | 87 | //@} |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * Context for storing H.264 prediction functions |
| 91 | 91 | */ |
| 92 | −typedef struct H264PredContext{ | |
| 93 | − void (*pred4x4 [9+3+3])(uint8_t *src, const uint8_t *topright, int stride);//FIXME move to dsp? | |
| 94 | − void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride); | |
| 95 | − void (*pred8x8 [4+3+4])(uint8_t *src, int stride); | |
| 96 | − void (*pred16x16[4+3+2])(uint8_t *src, int stride); | |
| 92 | +typedef struct H264PredContext { | |
| 93 | + void(*pred4x4[9 + 3 + 3])(uint8_t *src, const uint8_t *topright, int stride); //FIXME move to dsp? | |
| 94 | + void(*pred8x8l[9 + 3])(uint8_t *src, int topleft, int topright, int stride); | |
| 95 | + void(*pred8x8[4 + 3 + 4])(uint8_t *src, int stride); | |
| 96 | + void(*pred16x16[4 + 3 + 2])(uint8_t *src, int stride); | |
| 97 | 97 | |
| 98 | − void (*pred4x4_add [2])(uint8_t *pix/*align 4*/, const DCTELEM *block/*align 16*/, int stride); | |
| 99 | − void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, const DCTELEM *block/*align 16*/, int stride); | |
| 100 | − void (*pred8x8_add [3])(uint8_t *pix/*align 8*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | |
| 101 | − void (*pred16x16_add[3])(uint8_t *pix/*align 16*/, const int *block_offset, const DCTELEM *block/*align 16*/, int stride); | |
| 102 | −}H264PredContext; | |
| 98 | + void(*pred4x4_add[2])(uint8_t *pix /*align 4*/, | |
| 99 | + const DCTELEM *block /*align 16*/, int stride); | |
| 100 | + void(*pred8x8l_add[2])(uint8_t *pix /*align 8*/, | |
| 101 | + const DCTELEM *block /*align 16*/, int stride); | |
| 102 | + void(*pred8x8_add[3])(uint8_t *pix /*align 8*/, | |
| 103 | + const int *block_offset, | |
| 104 | + const DCTELEM *block /*align 16*/, int stride); | |
| 105 | + void(*pred16x16_add[3])(uint8_t *pix /*align 16*/, | |
| 106 | + const int *block_offset, | |
| 107 | + const DCTELEM *block /*align 16*/, int stride); | |
| 108 | +} H264PredContext; | |
| 103 | 109 | |
| 104 | −void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 105 | −void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 106 | −void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc); | |
| 110 | +void ff_h264_pred_init(H264PredContext *h, int codec_id, | |
| 111 | + const int bit_depth, const int chroma_format_idc); | |
| 112 | +void ff_h264_pred_init_arm(H264PredContext *h, int codec_id, | |
| 113 | + const int bit_depth, const int chroma_format_idc); | |
| 114 | +void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, | |
| 115 | + const int bit_depth, const int chroma_format_idc); | |
| 107 | 116 | |
| 108 | 117 | #endif /* AVCODEC_H264PRED_H */ |