2
0

vp9_block.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VP9_ENCODER_VP9_BLOCK_H_
  11. #define VP9_ENCODER_VP9_BLOCK_H_
  12. #include "vp9/common/vp9_entropymv.h"
  13. #include "vp9/common/vp9_entropy.h"
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. typedef struct {
  18. unsigned int sse;
  19. int sum;
  20. unsigned int var;
  21. } diff;
  22. struct macroblock_plane {
  23. DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
  24. tran_low_t *qcoeff;
  25. tran_low_t *coeff;
  26. uint16_t *eobs;
  27. struct buf_2d src;
  28. // Quantizer setings
  29. int16_t *quant_fp;
  30. int16_t *round_fp;
  31. int16_t *quant;
  32. int16_t *quant_shift;
  33. int16_t *zbin;
  34. int16_t *round;
  35. int64_t quant_thred[2];
  36. };
  37. /* The [2] dimension is for whether we skip the EOB node (i.e. if previous
  38. * coefficient in this block was zero) or not. */
  39. typedef unsigned int vp9_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
  40. [COEFF_CONTEXTS][ENTROPY_TOKENS];
  41. typedef struct {
  42. int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
  43. uint8_t mode_context[MAX_REF_FRAMES];
  44. } MB_MODE_INFO_EXT;
  45. typedef struct {
  46. int col_min;
  47. int col_max;
  48. int row_min;
  49. int row_max;
  50. } MvLimits;
  51. typedef struct macroblock MACROBLOCK;
  52. struct macroblock {
  53. struct macroblock_plane plane[MAX_MB_PLANE];
  54. MACROBLOCKD e_mbd;
  55. MB_MODE_INFO_EXT *mbmi_ext;
  56. MB_MODE_INFO_EXT *mbmi_ext_base;
  57. int skip_block;
  58. int select_tx_size;
  59. int skip_recode;
  60. int skip_optimize;
  61. int q_index;
  62. int block_qcoeff_opt;
  63. int block_tx_domain;
  64. // The equivalent error at the current rdmult of one whole bit (not one
  65. // bitcost unit).
  66. int errorperbit;
  67. // The equivalend SAD error of one (whole) bit at the current quantizer
  68. // for large blocks.
  69. int sadperbit16;
  70. // The equivalend SAD error of one (whole) bit at the current quantizer
  71. // for sub-8x8 blocks.
  72. int sadperbit4;
  73. int rddiv;
  74. int rdmult;
  75. int mb_energy;
  76. int *m_search_count_ptr;
  77. int *ex_search_count_ptr;
  78. // These are set to their default values at the beginning, and then adjusted
  79. // further in the encoding process.
  80. BLOCK_SIZE min_partition_size;
  81. BLOCK_SIZE max_partition_size;
  82. int mv_best_ref_index[MAX_REF_FRAMES];
  83. unsigned int max_mv_context[MAX_REF_FRAMES];
  84. unsigned int source_variance;
  85. unsigned int pred_sse[MAX_REF_FRAMES];
  86. int pred_mv_sad[MAX_REF_FRAMES];
  87. int nmvjointcost[MV_JOINTS];
  88. int *nmvcost[2];
  89. int *nmvcost_hp[2];
  90. int **mvcost;
  91. int nmvjointsadcost[MV_JOINTS];
  92. int *nmvsadcost[2];
  93. int *nmvsadcost_hp[2];
  94. int **mvsadcost;
  95. // These define limits to motion vector components to prevent them
  96. // from extending outside the UMV borders
  97. MvLimits mv_limits;
  98. // Notes transform blocks where no coefficents are coded.
  99. // Set during mode selection. Read during block encoding.
  100. uint8_t zcoeff_blk[TX_SIZES][256];
  101. int skip;
  102. int encode_breakout;
  103. // note that token_costs is the cost when eob node is skipped
  104. vp9_coeff_cost token_costs[TX_SIZES];
  105. int optimize;
  106. // indicate if it is in the rd search loop or encoding process
  107. int use_lp32x32fdct;
  108. int skip_encode;
  109. // use fast quantization process
  110. int quant_fp;
  111. // skip forward transform and quantization
  112. uint8_t skip_txfm[MAX_MB_PLANE << 2];
  113. #define SKIP_TXFM_NONE 0
  114. #define SKIP_TXFM_AC_DC 1
  115. #define SKIP_TXFM_AC_ONLY 2
  116. int64_t bsse[MAX_MB_PLANE << 2];
  117. // Used to store sub partition's choices.
  118. MV pred_mv[MAX_REF_FRAMES];
  119. // Strong color activity detection. Used in RTC coding mode to enhance
  120. // the visual quality at the boundary of moving color objects.
  121. uint8_t color_sensitivity[2];
  122. uint8_t sb_is_skin;
  123. // Used to save the status of whether a block has a low variance in
  124. // choose_partitioning. 0 for 64x64, 1~2 for 64x32, 3~4 for 32x64, 5~8 for
  125. // 32x32, 9~24 for 16x16.
  126. uint8_t variance_low[25];
  127. void (*fwd_txm4x4)(const int16_t *input, tran_low_t *output, int stride);
  128. void (*itxm_add)(const tran_low_t *input, uint8_t *dest, int stride, int eob);
  129. #if CONFIG_VP9_HIGHBITDEPTH
  130. void (*highbd_itxm_add)(const tran_low_t *input, uint8_t *dest, int stride,
  131. int eob, int bd);
  132. #endif
  133. };
  134. #ifdef __cplusplus
  135. } // extern "C"
  136. #endif
  137. #endif // VP9_ENCODER_VP9_BLOCK_H_