vp9_block.h 3.71 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  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.
John Koleszar's avatar
John Koleszar committed
9
10
 */

11
12
#ifndef VP9_ENCODER_VP9_BLOCK_H_
#define VP9_ENCODER_VP9_BLOCK_H_
John Koleszar's avatar
John Koleszar committed
13

14
15
#include "vp9/common/vp9_entropymv.h"
#include "vp9/common/vp9_entropy.h"
John Koleszar's avatar
John Koleszar committed
16

17
18
19
20
#ifdef __cplusplus
extern "C" {
#endif

21
22
23
24
25
26
typedef struct {
  unsigned int sse;
  int sum;
  unsigned int var;
} diff;

27
struct macroblock_plane {
28
  DECLARE_ALIGNED(16, int16_t, src_diff[64 * 64]);
29
30
  tran_low_t *qcoeff;
  tran_low_t *coeff;
31
  uint16_t *eobs;
John Koleszar's avatar
John Koleszar committed
32
  struct buf_2d src;
33
34

  // Quantizer setings
35
  int16_t *quant_fp;
Jingning Han's avatar
Jingning Han committed
36
  int16_t *round_fp;
37
  int16_t *quant;
38
  int16_t *quant_shift;
39
40
41
  int16_t *zbin;
  int16_t *round;

42
  int64_t quant_thred[2];
43
44
};

45
46
/* The [2] dimension is for whether we skip the EOB node (i.e. if previous
 * coefficient in this block was zero) or not. */
47
typedef unsigned int vp9_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
48
                                   [COEFF_CONTEXTS][ENTROPY_TOKENS];
49

50
51
52
53
54
typedef struct {
  int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
  uint8_t mode_context[MAX_REF_FRAMES];
} MB_MODE_INFO_EXT;

55
56
typedef struct macroblock MACROBLOCK;
struct macroblock {
57
  struct macroblock_plane plane[MAX_MB_PLANE];
John Koleszar's avatar
John Koleszar committed
58
59

  MACROBLOCKD e_mbd;
60
61
  MB_MODE_INFO_EXT *mbmi_ext;
  MB_MODE_INFO_EXT *mbmi_ext_base;
John Koleszar's avatar
John Koleszar committed
62
  int skip_block;
63
  int select_tx_size;
64
  int skip_recode;
65
  int skip_optimize;
66
  int q_index;
John Koleszar's avatar
John Koleszar committed
67
68
69
70
71
72

  int errorperbit;
  int sadperbit16;
  int sadperbit4;
  int rddiv;
  int rdmult;
73
  int mb_energy;
John Koleszar's avatar
John Koleszar committed
74

75
76
77
78
79
  // These are set to their default values at the beginning, and then adjusted
  // further in the encoding process.
  BLOCK_SIZE min_partition_size;
  BLOCK_SIZE max_partition_size;

80
  int mv_best_ref_index[MAX_REF_FRAMES];
81
  unsigned int max_mv_context[MAX_REF_FRAMES];
82
  unsigned int source_variance;
83
84
  unsigned int pred_sse[MAX_REF_FRAMES];
  int pred_mv_sad[MAX_REF_FRAMES];
85

86
87
88
  int nmvjointcost[MV_JOINTS];
  int *nmvcost[2];
  int *nmvcost_hp[2];
89
  int **mvcost;
90
91
92
93

  int nmvjointsadcost[MV_JOINTS];
  int *nmvsadcost[2];
  int *nmvsadcost_hp[2];
94
  int **mvsadcost;
95

96
97
  // These define limits to motion vector components to prevent them
  // from extending outside the UMV borders
John Koleszar's avatar
John Koleszar committed
98
99
100
101
  int mv_col_min;
  int mv_col_max;
  int mv_row_min;
  int mv_row_max;
John Koleszar's avatar
John Koleszar committed
102

Alex Converse's avatar
Alex Converse committed
103
104
  // Notes transform blocks where no coefficents are coded.
  // Set during mode selection. Read during block encoding.
105
  uint8_t zcoeff_blk[TX_SIZES][256];
Alex Converse's avatar
Alex Converse committed
106

John Koleszar's avatar
John Koleszar committed
107
  int skip;
John Koleszar's avatar
John Koleszar committed
108

John Koleszar's avatar
John Koleszar committed
109
  int encode_breakout;
John Koleszar's avatar
John Koleszar committed
110

111
  // note that token_costs is the cost when eob node is skipped
112
  vp9_coeff_cost token_costs[TX_SIZES];
113

John Koleszar's avatar
John Koleszar committed
114
  int optimize;
John Koleszar's avatar
John Koleszar committed
115

116
  // indicate if it is in the rd search loop or encoding process
117
  int use_lp32x32fdct;
118
  int skip_encode;
119

Jingning Han's avatar
Jingning Han committed
120
121
122
  // use fast quantization process
  int quant_fp;

123
  // skip forward transform and quantization
124
  uint8_t skip_txfm[MAX_MB_PLANE << 2];
125

126
  int64_t bsse[MAX_MB_PLANE << 2];
127

128
  // Used to store sub partition's choices.
Dmitry Kovalev's avatar
Dmitry Kovalev committed
129
  MV pred_mv[MAX_REF_FRAMES];
130

131
132
133
134
  // Strong color activity detection. Used in RTC coding mode to enhance
  // the visual quality at the boundary of moving color objects.
  uint8_t color_sensitivity[2];

135
136
137
  void (*fwd_txm4x4)(const int16_t *input, tran_low_t *output, int stride);
  void (*itxm_add)(const tran_low_t *input, uint8_t *dest, int stride, int eob);
#if CONFIG_VP9_HIGHBITDEPTH
138
139
  void (*highbd_itxm_add)(const tran_low_t *input, uint8_t *dest, int stride,
                          int eob, int bd);
140
#endif
141
};
John Koleszar's avatar
John Koleszar committed
142

143
144
145
146
#ifdef __cplusplus
}  // extern "C"
#endif

147
#endif  // VP9_ENCODER_VP9_BLOCK_H_