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
3737 #include "rectangle.h"
3838
3939 #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
4141
42−#define MAX_SPS_COUNT 32
43−#define MAX_PPS_COUNT 256
42+#define MAX_SPS_COUNT 32
43+#define MAX_PPS_COUNT 256
4444
45−#define MAX_MMCO_COUNT 66
45+#define MAX_MMCO_COUNT 66
4646
47−#define MAX_DELAYED_PIC_COUNT 16
47+#define MAX_DELAYED_PIC_COUNT 16
4848
4949 /* Compiling in interlaced support reduces the speed
5050 * of progressive decoding by about 2%. */
@@ -59,25 +59,25 @@ · 8 unmodified lines
5959 #define MAX_SLICES 16
6060
6161 #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
6464 #define FRAME_MBAFF h->mb_aff_frame
6565 #define FIELD_PICTURE (s->picture_structure != PICT_FRAME)
6666 #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)
7070 #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
7474 #define FIELD_PICTURE 0
7575 #undef IS_INTERLACED
7676 #define IS_INTERLACED(mb_type) 0
7777 #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
8181 #endif
8282 #define FIELD_OR_MBAFF_PICTURE (FRAME_MBAFF || FIELD_PICTURE)
8383
@@ -88,9 +88,9 @@ · 4 unmodified lines
8888 #define CHROMA422 (h->sps.chroma_format_idc == 2)
8989 #define CHROMA444 (h->sps.chroma_format_idc == 3)
9090
91−#define EXTENDED_SAR 255
91+#define EXTENDED_SAR 255
9292
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
9494 #define MB_TYPE_8x8DCT 0x01000000
9595 #define IS_REF0(a) ((a) & MB_TYPE_REF0)
9696 #define IS_8x8DCT(a) ((a) & MB_TYPE_8x8DCT)
@@ -101,11 +101,11 @@ · 4 unmodified lines
101101 */
102102 #define DELAYED_PIC_REF 4
103103
104−#define QP_MAX_NUM (51 + 2*6) // The maximum supported qp
104+#define QP_MAX_NUM (51 + 2 * 6) // The maximum supported qp
105105
106106 /* NAL unit types */
107107 enum {
108− NAL_SLICE=1,
108+ NAL_SLICE = 1,
109109 NAL_DPA,
110110 NAL_DPB,
111111 NAL_DPC,
@@ -118,17 +118,17 @@ enum { · 6 unmodified lines
118118 NAL_END_STREAM,
119119 NAL_FILLER_DATA,
120120 NAL_SPS_EXT,
121− NAL_AUXILIARY_SLICE=19
121+ NAL_AUXILIARY_SLICE = 19
122122 };
123123
124124 /**
125125 * SEI message types
126126 */
127127 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)
132132 } SEI_Type;
133133
134134 /**
@@ -149,8 +149,7 @@ typedef enum { · 14 unmodified lines
149149 /**
150150 * Sequence parameter set
151151 */
152−typedef struct SPS{
153−
152+typedef struct SPS {
154153 int profile_idc;
155154 int level_idc;
156155 int chroma_format_idc;
@@ -167,9 +166,9 @@ typedef struct SPS{ · 10 unmodified lines
167166 int mb_width; ///< pic_width_in_mbs_minus1 + 1
168167 int mb_height; ///< pic_height_in_map_units_minus1 + 1
169168 int frame_mbs_only_flag;
170− int mb_aff; ///<mb_adaptive_frame_field_flag
169+ int mb_aff; ///< mb_adaptive_frame_field_flag
171170 int direct_8x8_inference_flag;
172− int crop; ///< frame_cropping_flag
171+ int crop; ///< frame_cropping_flag
173172 unsigned int crop_left; ///< frame_cropping_rect_left_offset
174173 unsigned int crop_right; ///< frame_cropping_rect_right_offset
175174 unsigned int crop_top; ///< frame_cropping_rect_top_offset
@@ -186,7 +185,7 @@ typedef struct SPS{ · 10 unmodified lines
186185 uint32_t num_units_in_tick;
187186 uint32_t time_scale;
188187 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?
190189 int bitstream_restriction_flag;
191190 int num_reorder_frames;
192191 int scaling_matrix_present;
@@ -196,20 +195,20 @@ typedef struct SPS{ · 3 unmodified lines
196195 int vcl_hrd_parameters_present_flag;
197196 int pic_struct_present_flag;
198197 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;
208207
209208 /**
210209 * Picture parameter set
211210 */
212−typedef struct PPS{
211+typedef struct PPS {
213212 unsigned int sps_id;
214213 int cabac; ///< entropy_coding_mode_flag
215214 int pic_order_present; ///< pic_order_present_flag
@@ -222,20 +221,20 @@ typedef struct PPS{ · 6 unmodified lines
222221 int init_qs; ///< pic_init_qs_minus26 + 26
223222 int chroma_qp_index_offset[2];
224223 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
228227 uint8_t scaling_matrix4[6][16];
229228 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
231230 int chroma_qp_diff;
232−}PPS;
231+} PPS;
233232
234233 /**
235234 * Memory management control operation opcode.
236235 */
237−typedef enum MMCOOpcode{
238− MMCO_END=0,
236+typedef enum MMCOOpcode {
237+ MMCO_END = 0,
239238 MMCO_SHORT2UNUSED,
240239 MMCO_LONG2UNUSED,
241240 MMCO_SHORT2LONG,
@@ -247,7 +246,7 @@ typedef enum MMCOOpcode{ · 5 unmodified lines
247246 /**
248247 * Memory management control operation.
249248 */
250−typedef struct MMCO{
249+typedef struct MMCO {
251250 MMCOOpcode opcode;
252251 int short_pic_num; ///< pic_num without wrapping (pic_num & max_pic_num)
253252 int long_arg; ///< index, pic_num, or num long refs depending on opcode
@@ -256,18 +255,18 @@ typedef struct MMCO{ · 2 unmodified lines
256255 /**
257256 * H264Context
258257 */
259−typedef struct H264Context{
258+typedef struct H264Context {
260259 MpegEncContext s;
261260 H264DSPContext h264dsp;
262261 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
264263
265264 int qp_thresh; ///< QP threshold to skip loopfilter
266265
267266 int prev_mb_skipped;
268267 int next_mb_skipped;
269268
270− //prediction stuff
269+ // prediction stuff
271270 int chroma_pred_mode;
272271 int intra16x16_pred_mode;
273272
@@ -281,32 +280,32 @@ typedef struct H264Context{ · 7 unmodified lines
281280 int topright_type;
282281 int left_type[LEFT_MBS];
283282
284− const uint8_t * left_block;
283+ const uint8_t *left_block;
285284 int topleft_partition;
286285
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);
289288 H264PredContext hpc;
290289 unsigned int topleft_samples_available;
291290 unsigned int top_samples_available;
292291 unsigned int topright_samples_available;
293292 unsigned int left_samples_available;
294− uint8_t (*top_borders[2])[(16*3)*2];
293+ uint8_t (*top_borders[2])[(16 * 3) * 2];
295294
296295 /**
297296 * non zero coeff count cache.
298297 * is 64 if not available.
299298 */
300− DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15*8];
299+ DECLARE_ALIGNED(8, uint8_t, non_zero_count_cache)[15 * 8];
301300
302301 uint8_t (*non_zero_count)[48];
303302
304303 /**
305304 * Motion vector cache.
306305 */
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?
310309 #define PART_NOT_AVAILABLE -2
311310
312311 /**
@@ -318,13 +317,13 @@ typedef struct H264Context{ · 5 unmodified lines
318317 * block_offset[ 0..23] for frame macroblocks
319318 * block_offset[24..47] for field macroblocks
320319 */
321− int block_offset[2*(16*3)];
320+ int block_offset[2 * (16 * 3)];
322321
323− uint32_t *mb2b_xy; //FIXME are these 4 a good idea?
322+ uint32_t *mb2b_xy; // FIXME are these 4 a good idea?
324323 uint32_t *mb2br_xy;
325− int b_stride; //FIXME use s->b4_stride
324+ int b_stride; // FIXME use s->b4_stride
326325
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
328327 int mb_uvlinesize;
329328
330329 int emu_edge_width;
@@ -335,32 +334,32 @@ typedef struct H264Context{ · 4 unmodified lines
335334 /**
336335 * current pps
337336 */
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?
339338
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];
344343
345344 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
347346 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)
349348 int slice_type_fixed;
350349
351− //interlacing specific flags
350+ // interlacing specific flags
352351 int mb_aff_frame;
353352 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
355354
356355 DECLARE_ALIGNED(8, uint16_t, sub_mb_type)[4];
357356
358− //Weighted pred stuff
357+ // Weighted pred stuff
359358 int use_weight;
360359 int use_weight_chroma;
361360 int luma_log2_weight_denom;
362361 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
364363 int luma_weight[48][2][2];
365364 int chroma_weight[48][2][2][2];
366365 int implicit_weight[48][48][2];
@@ -370,48 +369,48 @@ typedef struct H264Context{ · 3 unmodified lines
370369 int col_fieldoff;
371370 int dist_scale_factor[16];
372371 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];
375374
376375 /**
377376 * num_ref_idx_l0/1_active_minus1 + 1
378377 */
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
380379 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
386385
387− //data partitioning
386+ // data partitioning
388387 GetBitContext intra_gb;
389388 GetBitContext inter_gb;
390389 GetBitContext *intra_gb_ptr;
391390 GetBitContext *inter_gb_ptr;
392391
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
396395
397396 /**
398397 * Cabac
399398 */
400399 CABACContext cabac;
401− uint8_t cabac_state[1024];
400+ uint8_t cabac_state[1024];
402401
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;
405404 int cbp;
406405 int top_cbp;
407406 int left_cbp;
408407 /* 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];
415414
416415 uint8_t zigzag_scan[16];
417416 uint8_t zigzag_scan8x8[64];
@@ -432,13 +431,13 @@ typedef struct H264Context{ · 14 unmodified lines
432431
433432 int is_complex;
434433
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
437436 int slice_alpha_c0_offset;
438437 int slice_beta_offset;
439438
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
442441
443442 int nal_ref_idc;
444443 int nal_unit_type;
@@ -448,37 +447,36 @@ typedef struct H264Context{ · 3 unmodified lines
448447 /**
449448 * Used to parse AVC variant of h264
450449 */
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
454453
455454 SPS *sps_buffers[MAX_SPS_COUNT];
456455 PPS *pps_buffers[MAX_PPS_COUNT];
457456
458− int dequant_coeff_pps; ///< reinit tables when pps changes
457+ int dequant_coeff_pps; ///< reinit tables when pps changes
459458
460459 uint16_t *slice_table_base;
461460
462−
463− //POC stuff
461+ // POC stuff
464462 int poc_lsb;
465463 int poc_msb;
466464 int delta_poc_bottom;
467465 int delta_poc[2];
468466 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
474472
475473 /**
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.
477475 */
478476 int curr_pic_num;
479477
480478 /**
481− * max_frame_num or 2*max_frame_num for field pics.
479+ * max_frame_num or 2 * max_frame_num for field pics.
482480 */
483481 int max_pic_num;
484482
@@ -487,7 +485,7 @@ typedef struct H264Context{ · 2 unmodified lines
487485 Picture *short_ref[32];
488486 Picture *long_ref[32];
489487 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?
491489 int last_pocs[MAX_DELAYED_PIC_COUNT];
492490 Picture *next_output_pic;
493491 int outputed_poc;
@@ -500,10 +498,10 @@ typedef struct H264Context{ · 6 unmodified lines
500498 int mmco_index;
501499 int mmco_reset;
502500
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
505503
506− int cabac_init_idc;
504+ int cabac_init_idc;
507505
508506 /**
509507 * @name Members for slice based multithreading
@@ -572,18 +570,17 @@ typedef struct H264Context{ · 62 unmodified lines
572570 */
573571 int sei_recovery_frame_cnt;
574572
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
577575
578576 // 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
581579
582580 int cur_chroma_format_idc;
583−}H264Context;
581+} H264Context;
584582
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).
587584 extern const uint16_t ff_h264_mb_sizes[4];
588585
589586 /**
@@ -610,13 +607,16 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length); · 20 unmodified lines
610607 * Decode a network abstraction layer unit.
611608 * @param consumed is the number of bytes used as input
612609 * @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?
614612 * @return decoded bytes, might be src+1 if no escapes
615613 */
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);
617616
618617 /**
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.
620620 */
621621 av_cold void ff_h264_free_context(H264Context *h);
622622
@@ -649,14 +649,15 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb); · 26 unmodified lines
649649
650650 void ff_generate_sliding_window_mmcos(H264Context *h);
651651
652−
653652 /**
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.
655655 */
656656 int ff_h264_check_intra4x4_pred_mode(H264Context *h);
657657
658658 /**
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.
660661 */
661662 int ff_h264_check_intra_pred_mode(H264Context *h, int mode, int is_chroma);
662663
@@ -668,24 +669,28 @@ av_cold void ff_h264_decode_init_vlc(void); · 5 unmodified lines
668669
669670 /**
670671 * 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
672673 */
673674 int ff_h264_decode_mb_cavlc(H264Context *h);
674675
675676 /**
676677 * 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
678679 */
679680 int ff_h264_decode_mb_cabac(H264Context *h);
680681
681682 void ff_h264_init_cabac_states(H264Context *h);
682683
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);
686687
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);
689694
690695 /**
691696 * 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
694699 */
695700 void ff_h264_reset_sei(H264Context *h);
696701
697−
698702 /*
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+ */
707711
708712 /* Scan8 organization:
709713 * 0 1 2 3 4 5 6 7
@@ -728,156 +732,173 @@ o-o o-o · 18 unmodified lines
728732 #define LUMA_DC_BLOCK_INDEX 48
729733 #define CHROMA_DC_BLOCK_INDEX 49
730734
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
746750 };
747751
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+{
749754 #if HAVE_BIGENDIAN
750− return (b&0xFFFF) + (a<<16);
755+ return (b & 0xFFFF) + (a << 16);
751756 #else
752− return (a&0xFFFF) + (b<<16);
757+ return (a & 0xFFFF) + (b << 16);
753758 #endif
754759 }
755760
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+{
757763 #if HAVE_BIGENDIAN
758− return (b&0xFF) + (a<<8);
764+ return (b & 0xFF) + (a << 8);
759765 #else
760− return (a&0xFF) + (b<<8);
766+ return (a & 0xFF) + (b << 8);
761767 #endif
762768 }
763769
764770 /**
765771 * Get the chroma qp.
766772 */
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+{
768775 return h->pps.chroma_qp_table[t][qscale];
769776 }
770777
771778 /**
772779 * Get the predicted intra4x4 prediction mode.
773780 */
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);
779787
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);
781789
782− if(min<0) return DC_PRED;
783− else return min;
790+ if (min < 0)
791+ return DC_PRED;
792+ else
793+ return min;
784794 }
785795
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;
789800
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];
794805 }
795806
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];
799811 uint8_t *nnz_cache = h->non_zero_count_cache;
800812
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]);
815827 }
816828 }
817829
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)
820835 {
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)) {
831847 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);
837853 }
838854 }
839855
840856 {
841857 int8_t *ref_index = &s->current_picture.f.ref_index[list][b8_xy];
842858 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]];
847863 }
848864 }
849865
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;
855872
856− if(USES_LIST(mb_type, 0)){
873+ if (USES_LIST(mb_type, 0)) {
857874 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 0);
858− }else{
875+ } else {
859876 fill_rectangle(&s->current_picture.f.ref_index[0][b8_xy],
860877 2, 2, 2, (uint8_t)LIST_NOT_USED, 1);
861878 }
862− if(USES_LIST(mb_type, 1)){
879+ if (USES_LIST(mb_type, 1))
863880 write_back_motion_list(h, s, b_stride, b_xy, b8_xy, mb_type, 1);
864− }
865881
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;
872888 }
873889 }
874890 }
875891
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));
879898 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));
881902 }
882903
883904 #endif /* AVCODEC_H264_H */
libavcodec/h264data.h+186−183
@@ -30,240 +30,243 @@ · 29 unmodified lines
3030 #define AVCODEC_H264DATA_H
3131
3232 #include <stdint.h>
33+
3334 #include "libavutil/rational.h"
3435 #include "mpegvideo.h"
3536 #include "h264.h"
3637
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+};
3742
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
4547 };
4648
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
5153 };
5254
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,
5860 };
5961
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,
6567 };
6668
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,
7274 };
7375
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,
7981 };
8082
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,
8486 };
8587
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,
9193 };
9294
9395 // 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,
111113 };
112114
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,
130132 };
131133
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,
149151 };
150152
151−typedef struct IMbInfo{
153+typedef struct IMbInfo {
152154 uint16_t type;
153155 uint8_t pred_mode;
154156 uint8_t cbp;
155157 } IMbInfo;
156158
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 },
184186 };
185187
186−typedef struct PMbInfo{
188+typedef struct PMbInfo {
187189 uint16_t type;
188190 uint8_t partition_count;
189191 } PMbInfo;
190192
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 },
197199 };
198200
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 },
204206 };
205207
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, },
230232 };
231233
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, },
246248 };
247249
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 },
255257 };
256258
257259 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
259261 };
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 },
267270 };
268271
269272 #endif /* AVCODEC_H264DATA_H */
libavcodec/h264pred.h+45−36
@@ -35,18 +35,18 @@ · 34 unmodified lines
3535 * Prediction types
3636 */
3737 //@{
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
4747
4848 // DC edge (not for VP8)
49−#define LEFT_DC_PRED 9
49+#define LEFT_DC_PRED 9
5050 #define TOP_DC_PRED 10
5151 #define DC_128_PRED 11
5252
@@ -56,7 +56,7 @@ · 3 unmodified lines
5656 #define VERT_LEFT_PRED_RV40_NODOWN 14
5757
5858 // 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
6060 #define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
6161 ///< (left col+cur col x2+right col) / 4;
6262 ///< this is the "unaveraged" one
@@ -65,44 +65,53 @@ · 2 unmodified lines
6565 #define DC_127_PRED 12
6666 #define DC_129_PRED 13
6767
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
7272
7373 // 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
7777
7878 // 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
8282 #define ALZHEIMER_DC_0L0_PRED8x8 10
8383
8484 // 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
8787 //@}
8888
8989 /**
9090 * Context for storing H.264 prediction functions
9191 */
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);
9797
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;
103109
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);
107116
108117 #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