Mercurial > libavcodec.hg
comparison h264.h @ 11348:3c624d573966 libavcodec
Move all context fields that are not used in the mb and block layers
to the end of the structure.
4 cpu cycles faster in 3k cpu cycles
author | michael |
---|---|
date | Wed, 03 Mar 2010 20:36:56 +0000 |
parents | a8b76b8455bc |
children | 33f8308382f5 |
comparison
equal
deleted
inserted
replaced
11347:d48922f77738 | 11348:3c624d573966 |
---|---|
260 /** | 260 /** |
261 * H264Context | 261 * H264Context |
262 */ | 262 */ |
263 typedef struct H264Context{ | 263 typedef struct H264Context{ |
264 MpegEncContext s; | 264 MpegEncContext s; |
265 int nal_ref_idc; | |
266 int nal_unit_type; | |
267 uint8_t *rbsp_buffer[2]; | |
268 unsigned int rbsp_buffer_size[2]; | |
269 | |
270 /** | |
271 * Used to parse AVC variant of h264 | |
272 */ | |
273 int is_avc; ///< this flag is != 0 if codec is avc1 | |
274 int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | |
275 | |
276 int chroma_qp[2]; //QPc | 265 int chroma_qp[2]; //QPc |
277 | 266 |
278 int qp_thresh; ///< QP threshold to skip loopfilter | 267 int qp_thresh; ///< QP threshold to skip loopfilter |
279 | 268 |
280 int prev_mb_skipped; | 269 int prev_mb_skipped; |
352 int mb_uvlinesize; | 341 int mb_uvlinesize; |
353 | 342 |
354 int emu_edge_width; | 343 int emu_edge_width; |
355 int emu_edge_height; | 344 int emu_edge_height; |
356 | 345 |
357 SPS *sps_buffers[MAX_SPS_COUNT]; | |
358 SPS sps; ///< current sps | 346 SPS sps; ///< current sps |
359 | 347 |
360 PPS *pps_buffers[MAX_PPS_COUNT]; | |
361 /** | 348 /** |
362 * current pps | 349 * current pps |
363 */ | 350 */ |
364 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? | 351 PPS pps; //FIXME move to Picture perhaps? (->no) do we need that? |
365 | 352 |
366 uint32_t dequant4_buffer[6][52][16]; | 353 uint32_t dequant4_buffer[6][52][16]; //FIXME should these be moved down? |
367 uint32_t dequant8_buffer[2][52][64]; | 354 uint32_t dequant8_buffer[2][52][64]; |
368 uint32_t (*dequant4_coeff[6])[16]; | 355 uint32_t (*dequant4_coeff[6])[16]; |
369 uint32_t (*dequant8_coeff[2])[64]; | 356 uint32_t (*dequant8_coeff[2])[64]; |
370 int dequant_coeff_pps; ///< reinit tables when pps changes | |
371 | 357 |
372 int slice_num; | 358 int slice_num; |
373 uint16_t *slice_table_base; | |
374 uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 | 359 uint16_t *slice_table; ///< slice_table_base + 2*mb_stride + 1 |
375 int slice_type; | 360 int slice_type; |
376 int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) | 361 int slice_type_nos; ///< S free slice type (SI/SP are remapped to I/P) |
377 int slice_type_fixed; | 362 int slice_type_fixed; |
378 | 363 |
380 int mb_aff_frame; | 365 int mb_aff_frame; |
381 int mb_field_decoding_flag; | 366 int mb_field_decoding_flag; |
382 int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag | 367 int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag |
383 | 368 |
384 DECLARE_ALIGNED_8(uint16_t, sub_mb_type)[4]; | 369 DECLARE_ALIGNED_8(uint16_t, sub_mb_type)[4]; |
385 | |
386 //POC stuff | |
387 int poc_lsb; | |
388 int poc_msb; | |
389 int delta_poc_bottom; | |
390 int delta_poc[2]; | |
391 int frame_num; | |
392 int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 | |
393 int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 | |
394 int frame_num_offset; ///< for POC type 2 | |
395 int prev_frame_num_offset; ///< for POC type 2 | |
396 int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 | |
397 | |
398 /** | |
399 * frame_num for frames or 2*frame_num+1 for field pics. | |
400 */ | |
401 int curr_pic_num; | |
402 | |
403 /** | |
404 * max_frame_num or 2*max_frame_num for field pics. | |
405 */ | |
406 int max_pic_num; | |
407 | 370 |
408 //Weighted pred stuff | 371 //Weighted pred stuff |
409 int use_weight; | 372 int use_weight; |
410 int use_weight_chroma; | 373 int use_weight_chroma; |
411 int luma_log2_weight_denom; | 374 int luma_log2_weight_denom; |
413 //The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss | 376 //The following 2 can be changed to int8_t but that causes 10cpu cycles speedloss |
414 int luma_weight[2][48][2]; | 377 int luma_weight[2][48][2]; |
415 int chroma_weight[2][48][2][2]; | 378 int chroma_weight[2][48][2][2]; |
416 int implicit_weight[48][48]; | 379 int implicit_weight[48][48]; |
417 | 380 |
418 //deblock | |
419 int deblocking_filter; ///< disable_deblocking_filter_idc with 1<->0 | |
420 int slice_alpha_c0_offset; | |
421 int slice_beta_offset; | |
422 | |
423 int redundant_pic_count; | |
424 | |
425 int direct_spatial_mv_pred; | 381 int direct_spatial_mv_pred; |
426 int col_parity; | 382 int col_parity; |
427 int col_fieldoff; | 383 int col_fieldoff; |
428 int dist_scale_factor[16]; | 384 int dist_scale_factor[16]; |
429 int dist_scale_factor_field[2][32]; | 385 int dist_scale_factor_field[2][32]; |
434 * num_ref_idx_l0/1_active_minus1 + 1 | 390 * num_ref_idx_l0/1_active_minus1 + 1 |
435 */ | 391 */ |
436 unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode | 392 unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode |
437 unsigned int list_count; | 393 unsigned int list_count; |
438 uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type | 394 uint8_t *list_counts; ///< Array of list_count per MB specifying the slice type |
439 Picture *short_ref[32]; | |
440 Picture *long_ref[32]; | |
441 Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture | |
442 Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. | 395 Picture ref_list[2][48]; /**< 0..15: frame refs, 16..47: mbaff field refs. |
443 Reordered version of default_ref_list | 396 Reordered version of default_ref_list |
444 according to picture reordering in slice header */ | 397 according to picture reordering in slice header */ |
445 int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 | 398 int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1 |
446 Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size? | |
447 int outputed_poc; | |
448 | |
449 /** | |
450 * memory management control operations buffer. | |
451 */ | |
452 MMCO mmco[MAX_MMCO_COUNT]; | |
453 int mmco_index; | |
454 | |
455 int long_ref_count; ///< number of actual long term references | |
456 int short_ref_count; ///< number of actual short term references | |
457 | 399 |
458 //data partitioning | 400 //data partitioning |
459 GetBitContext intra_gb; | 401 GetBitContext intra_gb; |
460 GetBitContext inter_gb; | 402 GetBitContext inter_gb; |
461 GetBitContext *intra_gb_ptr; | 403 GetBitContext *intra_gb_ptr; |
467 /** | 409 /** |
468 * Cabac | 410 * Cabac |
469 */ | 411 */ |
470 CABACContext cabac; | 412 CABACContext cabac; |
471 uint8_t cabac_state[460]; | 413 uint8_t cabac_state[460]; |
472 int cabac_init_idc; | |
473 | 414 |
474 /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */ | 415 /* 0x100 -> non null luma_dc, 0x80/0x40 -> non null chroma_dc (cb/cr), 0x?0 -> chroma_cbp(0,1,2), 0x0? luma_cbp */ |
475 uint16_t *cbp_table; | 416 uint16_t *cbp_table; |
476 int cbp; | 417 int cbp; |
477 int top_cbp; | 418 int top_cbp; |
497 const uint8_t *field_scan8x8_q0; | 438 const uint8_t *field_scan8x8_q0; |
498 const uint8_t *field_scan8x8_cavlc_q0; | 439 const uint8_t *field_scan8x8_cavlc_q0; |
499 | 440 |
500 int x264_build; | 441 int x264_build; |
501 | 442 |
443 int mb_xy; | |
444 | |
445 int is_complex; | |
446 | |
447 //deblock | |
448 int deblocking_filter; ///< disable_deblocking_filter_idc with 1<->0 | |
449 int slice_alpha_c0_offset; | |
450 int slice_beta_offset; | |
451 | |
452 //============================================================= | |
453 //Things below are not used in the MB or more inner code | |
454 | |
455 int nal_ref_idc; | |
456 int nal_unit_type; | |
457 uint8_t *rbsp_buffer[2]; | |
458 unsigned int rbsp_buffer_size[2]; | |
459 | |
460 /** | |
461 * Used to parse AVC variant of h264 | |
462 */ | |
463 int is_avc; ///< this flag is != 0 if codec is avc1 | |
464 int nal_length_size; ///< Number of bytes used for nal length (1, 2 or 4) | |
465 | |
466 SPS *sps_buffers[MAX_SPS_COUNT]; | |
467 PPS *pps_buffers[MAX_PPS_COUNT]; | |
468 | |
469 int dequant_coeff_pps; ///< reinit tables when pps changes | |
470 | |
471 uint16_t *slice_table_base; | |
472 | |
473 | |
474 //POC stuff | |
475 int poc_lsb; | |
476 int poc_msb; | |
477 int delta_poc_bottom; | |
478 int delta_poc[2]; | |
479 int frame_num; | |
480 int prev_poc_msb; ///< poc_msb of the last reference pic for POC type 0 | |
481 int prev_poc_lsb; ///< poc_lsb of the last reference pic for POC type 0 | |
482 int frame_num_offset; ///< for POC type 2 | |
483 int prev_frame_num_offset; ///< for POC type 2 | |
484 int prev_frame_num; ///< frame_num of the last pic for POC type 1/2 | |
485 | |
486 /** | |
487 * frame_num for frames or 2*frame_num+1 for field pics. | |
488 */ | |
489 int curr_pic_num; | |
490 | |
491 /** | |
492 * max_frame_num or 2*max_frame_num for field pics. | |
493 */ | |
494 int max_pic_num; | |
495 | |
496 int redundant_pic_count; | |
497 | |
498 Picture *short_ref[32]; | |
499 Picture *long_ref[32]; | |
500 Picture default_ref_list[2][32]; ///< base reference list for all slices of a coded picture | |
501 Picture *delayed_pic[MAX_DELAYED_PIC_COUNT+2]; //FIXME size? | |
502 int outputed_poc; | |
503 | |
504 /** | |
505 * memory management control operations buffer. | |
506 */ | |
507 MMCO mmco[MAX_MMCO_COUNT]; | |
508 int mmco_index; | |
509 | |
510 int long_ref_count; ///< number of actual long term references | |
511 int short_ref_count; ///< number of actual short term references | |
512 | |
513 int cabac_init_idc; | |
514 | |
502 /** | 515 /** |
503 * @defgroup multithreading Members for slice based multithreading | 516 * @defgroup multithreading Members for slice based multithreading |
504 * @{ | 517 * @{ |
505 */ | 518 */ |
506 struct H264Context *thread_context[MAX_THREADS]; | 519 struct H264Context *thread_context[MAX_THREADS]; |
524 */ | 537 */ |
525 int single_decode_warning; | 538 int single_decode_warning; |
526 | 539 |
527 int last_slice_type; | 540 int last_slice_type; |
528 /** @} */ | 541 /** @} */ |
529 | |
530 int mb_xy; | |
531 | 542 |
532 /** | 543 /** |
533 * pic_struct in picture timing SEI message | 544 * pic_struct in picture timing SEI message |
534 */ | 545 */ |
535 SEI_PicStructType sei_pic_struct; | 546 SEI_PicStructType sei_pic_struct; |
565 * Set to -1 if no recovery point SEI message found or to number of frames | 576 * Set to -1 if no recovery point SEI message found or to number of frames |
566 * before playback synchronizes. Frames having recovery point are key | 577 * before playback synchronizes. Frames having recovery point are key |
567 * frames. | 578 * frames. |
568 */ | 579 */ |
569 int sei_recovery_frame_cnt; | 580 int sei_recovery_frame_cnt; |
570 | |
571 int is_complex; | |
572 | 581 |
573 int luma_weight_flag[2]; ///< 7.4.3.2 luma_weight_lX_flag | 582 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 | 583 int chroma_weight_flag[2]; ///< 7.4.3.2 chroma_weight_lX_flag |
575 | 584 |
576 // Timestamp stuff | 585 // Timestamp stuff |