2d6dad306ba2e935f507dd65fc410b80ef8315e6
[profile/ivi/libvpx.git] / vp8 / common / loopfilter.h
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 loopfilter_h
13 #define loopfilter_h
14
15 #include "vpx_ports/mem.h"
16 #include "vpx_config.h"
17
18 #define MAX_LOOP_FILTER 63
19
20 typedef enum
21 {
22     NORMAL_LOOPFILTER = 0,
23     SIMPLE_LOOPFILTER = 1
24 } LOOPFILTERTYPE;
25
26 #if ARCH_ARM
27 #define SIMD_WIDTH 1
28 #else
29 #define SIMD_WIDTH 16
30 #endif
31
32 /* Need to align this structure so when it is declared and
33  * passed it can be loaded into vector registers.
34  */
35 typedef struct
36 {
37     DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
38     DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, blim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
39     DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
40     DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, hev_thr[4][SIMD_WIDTH]);
41     unsigned char lvl[4][4][4];
42     unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
43     unsigned char mode_lf_lut[10];
44 } loop_filter_info_n;
45
46 typedef struct
47 {
48     const unsigned char * mblim;
49     const unsigned char * blim;
50     const unsigned char * lim;
51     const unsigned char * hev_thr;
52 } loop_filter_info;
53
54
55 #define prototype_loopfilter(sym) \
56     void sym(unsigned char *src, int pitch, const unsigned char *blimit,\
57              const unsigned char *limit, const unsigned char *thresh, int count)
58
59 #define prototype_loopfilter_block(sym) \
60     void sym(unsigned char *y, unsigned char *u, unsigned char *v, \
61              int ystride, int uv_stride, loop_filter_info *lfi)
62
63 #define prototype_simple_loopfilter(sym) \
64     void sym(unsigned char *y, int ystride, const unsigned char *blimit)
65
66 #if ARCH_X86 || ARCH_X86_64
67 #include "x86/loopfilter_x86.h"
68 #endif
69
70 #if ARCH_ARM
71 #include "arm/loopfilter_arm.h"
72 #endif
73
74 #ifndef vp8_lf_normal_mb_v
75 #define vp8_lf_normal_mb_v vp8_loop_filter_mbv_c
76 #endif
77 extern prototype_loopfilter_block(vp8_lf_normal_mb_v);
78
79 #ifndef vp8_lf_normal_b_v
80 #define vp8_lf_normal_b_v vp8_loop_filter_bv_c
81 #endif
82 extern prototype_loopfilter_block(vp8_lf_normal_b_v);
83
84 #ifndef vp8_lf_normal_mb_h
85 #define vp8_lf_normal_mb_h vp8_loop_filter_mbh_c
86 #endif
87 extern prototype_loopfilter_block(vp8_lf_normal_mb_h);
88
89 #ifndef vp8_lf_normal_b_h
90 #define vp8_lf_normal_b_h vp8_loop_filter_bh_c
91 #endif
92 extern prototype_loopfilter_block(vp8_lf_normal_b_h);
93
94 #ifndef vp8_lf_simple_mb_v
95 #define vp8_lf_simple_mb_v vp8_loop_filter_simple_vertical_edge_c
96 #endif
97 extern prototype_simple_loopfilter(vp8_lf_simple_mb_v);
98
99 #ifndef vp8_lf_simple_b_v
100 #define vp8_lf_simple_b_v vp8_loop_filter_bvs_c
101 #endif
102 extern prototype_simple_loopfilter(vp8_lf_simple_b_v);
103
104 #ifndef vp8_lf_simple_mb_h
105 #define vp8_lf_simple_mb_h vp8_loop_filter_simple_horizontal_edge_c
106 #endif
107 extern prototype_simple_loopfilter(vp8_lf_simple_mb_h);
108
109 #ifndef vp8_lf_simple_b_h
110 #define vp8_lf_simple_b_h vp8_loop_filter_bhs_c
111 #endif
112 extern prototype_simple_loopfilter(vp8_lf_simple_b_h);
113
114 typedef prototype_loopfilter_block((*vp8_lf_block_fn_t));
115 typedef prototype_simple_loopfilter((*vp8_slf_block_fn_t));
116
117 typedef struct
118 {
119     vp8_lf_block_fn_t  normal_mb_v;
120     vp8_lf_block_fn_t  normal_b_v;
121     vp8_lf_block_fn_t  normal_mb_h;
122     vp8_lf_block_fn_t  normal_b_h;
123     vp8_slf_block_fn_t  simple_mb_v;
124     vp8_slf_block_fn_t  simple_b_v;
125     vp8_slf_block_fn_t  simple_mb_h;
126     vp8_slf_block_fn_t  simple_b_h;
127 } vp8_loopfilter_rtcd_vtable_t;
128
129 #if CONFIG_RUNTIME_CPU_DETECT
130 #define LF_INVOKE(ctx,fn) (ctx)->fn
131 #else
132 #define LF_INVOKE(ctx,fn) vp8_lf_##fn
133 #endif
134
135 typedef void loop_filter_uvfunction
136 (
137     unsigned char *u,   /* source pointer */
138     int p,              /* pitch */
139     const unsigned char *blimit,
140     const unsigned char *limit,
141     const unsigned char *thresh,
142     unsigned char *v
143 );
144
145 #endif