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