Merge "Fixed incorrect casts that broke rate control in some situations."
[profile/ivi/libvpx.git] / vp8 / encoder / block.h
1 /*
2  *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license and patent
5  *  grant that can be found in the LICENSE file in the root of the source
6  *  tree. All contributing project authors may be found in the AUTHORS
7  *  file in the root of the source tree.
8  */
9
10
11 #ifndef __INC_BLOCK_H
12 #define __INC_BLOCK_H
13
14 #include "onyx.h"
15 #include "blockd.h"
16 #include "entropymv.h"
17 #include "entropy.h"
18 #include "vpx_ports/mem.h"
19
20 // motion search site
21 typedef struct
22 {
23     MV mv;
24     int offset;
25 } search_site;
26
27 typedef struct
28 {
29     // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
30     short *src_diff;
31     short *coeff;
32
33     // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
34     short(*quant)[4];
35     short(*zbin)[4];
36     short(*zrun_zbin_boost);
37     short(*round)[4];
38
39     // Zbin Over Quant value
40     short zbin_extra;
41
42     unsigned char **base_src;
43     int src;
44     int src_stride;
45
46 //  MV  enc_mv;
47     int force_empty;
48
49 } BLOCK;
50
51 typedef struct
52 {
53     DECLARE_ALIGNED(16, short, src_diff[400]);       // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
54     DECLARE_ALIGNED(16, short, coeff[400]);     // 16x16 Y 8x8 U 8x8 V 4x4 2nd Y
55
56     // 16 Y blocks, 4 U blocks, 4 V blocks, 1 DC 2nd order block each with 16 entries
57     BLOCK block[25];
58
59     YV12_BUFFER_CONFIG src;
60
61     MACROBLOCKD e_mbd;
62
63     search_site *ss;
64     int ss_count;
65     int searches_per_step;
66
67     int errorperbit;
68     int sadperbit16;
69     int sadperbit4;
70     int errthresh;
71     int rddiv;
72     int rdmult;
73
74     int mvcosts[2][MVvals+1];
75     int *mvcost[2];
76     int mvsadcosts[2][MVvals+1];
77     int *mvsadcost[2];
78     int mbmode_cost[2][MB_MODE_COUNT];
79     int intra_uv_mode_cost[2][MB_MODE_COUNT];
80     unsigned int bmode_costs[10][10][10];
81     unsigned int inter_bmode_costs[B_MODE_COUNT];
82
83     // These define limits to motion vector components to prevent them from extending outside the UMV borders
84     int mv_col_min;
85     int mv_col_max;
86     int mv_row_min;
87     int mv_row_max;
88
89     int vector_range;    // Used to monitor limiting range of recent vectors to guide search.
90     int skip;
91
92     int encode_breakout;
93
94     unsigned char *active_ptr;
95     MV_CONTEXT *mvc;
96
97     unsigned int token_costs[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens];
98     int optimize;
99
100     void (*vp8_short_fdct4x4)(short *input, short *output, int pitch);
101     void (*vp8_short_fdct8x4)(short *input, short *output, int pitch);
102     void (*short_fdct4x4rd)(short *input, short *output, int pitch);
103     void (*short_fdct8x4rd)(short *input, short *output, int pitch);
104     void (*vp8_short_fdct4x4_ptr)(short *input, short *output, int pitch);
105     void (*short_walsh4x4)(short *input, short *output, int pitch);
106
107     void (*quantize_b)(BLOCK *b, BLOCKD *d);
108     void (*quantize_brd)(BLOCK *b, BLOCKD *d);
109
110
111
112 } MACROBLOCK;
113
114
115 #endif