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