History

h264: K&R formatting cosmetics for header files (part I/II)

Diego Biurrun committed 14 years ago

Commit be545b81 parent d55961f3 files · +491 −458Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t