Browse code

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

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