block.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 VPX_VP8_ENCODER_BLOCK_H_
  11. #define VPX_VP8_ENCODER_BLOCK_H_
  12. #include "vp8/common/onyx.h"
  13. #include "vp8/common/blockd.h"
  14. #include "vp8/common/entropymv.h"
  15. #include "vp8/common/entropy.h"
  16. #include "vpx_ports/mem.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define MAX_MODES 20
  21. #define MAX_ERROR_BINS 1024
  22. /* motion search site */
  23. typedef struct {
  24. MV mv;
  25. int offset;
  26. } search_site;
  27. typedef struct block {
  28. /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
  29. short *src_diff;
  30. short *coeff;
  31. /* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
  32. short *quant;
  33. short *quant_fast;
  34. short *quant_shift;
  35. short *zbin;
  36. short *zrun_zbin_boost;
  37. short *round;
  38. /* Zbin Over Quant value */
  39. short zbin_extra;
  40. unsigned char **base_src;
  41. int src;
  42. int src_stride;
  43. } BLOCK;
  44. typedef struct {
  45. int count;
  46. struct {
  47. B_PREDICTION_MODE mode;
  48. int_mv mv;
  49. } bmi[16];
  50. } PARTITION_INFO;
  51. typedef struct macroblock {
  52. DECLARE_ALIGNED(16, short, src_diff[400]); /* 25 blocks Y,U,V,Y2 */
  53. DECLARE_ALIGNED(16, short, coeff[400]); /* 25 blocks Y,U,V,Y2 */
  54. DECLARE_ALIGNED(16, unsigned char, thismb[256]);
  55. unsigned char *thismb_ptr;
  56. /* 16 Y, 4 U, 4 V, 1 DC 2nd order block */
  57. BLOCK block[25];
  58. YV12_BUFFER_CONFIG src;
  59. MACROBLOCKD e_mbd;
  60. PARTITION_INFO *partition_info; /* work pointer */
  61. PARTITION_INFO *pi; /* Corresponds to upper left visible macroblock */
  62. PARTITION_INFO *pip; /* Base of allocated array */
  63. int ref_frame_cost[MAX_REF_FRAMES];
  64. search_site *ss;
  65. int ss_count;
  66. int searches_per_step;
  67. int errorperbit;
  68. int sadperbit16;
  69. int sadperbit4;
  70. int rddiv;
  71. int rdmult;
  72. unsigned int *mb_activity_ptr;
  73. int *mb_norm_activity_ptr;
  74. signed int act_zbin_adj;
  75. signed int last_act_zbin_adj;
  76. int *mvcost[2];
  77. int *mvsadcost[2];
  78. int (*mbmode_cost)[MB_MODE_COUNT];
  79. int (*intra_uv_mode_cost)[MB_MODE_COUNT];
  80. int (*bmode_costs)[10][10];
  81. int *inter_bmode_costs;
  82. int (*token_costs)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
  83. /* These define limits to motion vector components to prevent
  84. * them from extending outside the UMV borders.
  85. */
  86. int mv_col_min;
  87. int mv_col_max;
  88. int mv_row_min;
  89. int mv_row_max;
  90. int skip;
  91. unsigned int encode_breakout;
  92. signed char *gf_active_ptr;
  93. unsigned char *active_ptr;
  94. MV_CONTEXT *mvc;
  95. int optimize;
  96. int q_index;
  97. int is_skin;
  98. int denoise_zeromv;
  99. #if CONFIG_TEMPORAL_DENOISING
  100. int increase_denoising;
  101. MB_PREDICTION_MODE best_sse_inter_mode;
  102. int_mv best_sse_mv;
  103. MV_REFERENCE_FRAME best_reference_frame;
  104. MV_REFERENCE_FRAME best_zeromv_reference_frame;
  105. unsigned char need_to_clamp_best_mvs;
  106. #endif
  107. int skip_true_count;
  108. unsigned int coef_counts[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
  109. [MAX_ENTROPY_TOKENS];
  110. unsigned int MVcount[2][MVvals]; /* (row,col) MV cts this frame */
  111. int ymode_count[VP8_YMODES]; /* intra MB type cts this frame */
  112. int uv_mode_count[VP8_UV_MODES]; /* intra MB type cts this frame */
  113. int64_t prediction_error;
  114. int64_t intra_error;
  115. int count_mb_ref_frame_usage[MAX_REF_FRAMES];
  116. int rd_thresh_mult[MAX_MODES];
  117. int rd_threshes[MAX_MODES];
  118. unsigned int mbs_tested_so_far;
  119. unsigned int mode_test_hit_counts[MAX_MODES];
  120. int zbin_mode_boost_enabled;
  121. int zbin_mode_boost;
  122. int last_zbin_mode_boost;
  123. int last_zbin_over_quant;
  124. int zbin_over_quant;
  125. int error_bins[MAX_ERROR_BINS];
  126. void (*short_fdct4x4)(short *input, short *output, int pitch);
  127. void (*short_fdct8x4)(short *input, short *output, int pitch);
  128. void (*short_walsh4x4)(short *input, short *output, int pitch);
  129. void (*quantize_b)(BLOCK *b, BLOCKD *d);
  130. unsigned int mbs_zero_last_dot_suppress;
  131. int zero_last_dot_suppress;
  132. } MACROBLOCK;
  133. #ifdef __cplusplus
  134. } // extern "C"
  135. #endif
  136. #endif // VPX_VP8_ENCODER_BLOCK_H_