loopfilter.h 4.93 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
13
14
15
 */


#ifndef loopfilter_h
#define loopfilter_h

#include "vpx_ports/mem.h"
Attila Nagy's avatar
Attila Nagy committed
16
#include "vpx_config.h"
John Koleszar's avatar
John Koleszar committed
17

18
19
20
21
#define MAX_LOOP_FILTER             63
/* fraction of total macroblock rows to be used in fast filter level picking */
/* has to be > 2 */
#define PARTIAL_FRAME_FRACTION      8
John Koleszar's avatar
John Koleszar committed
22
23
24
25
26
27
28

typedef enum
{
    NORMAL_LOOPFILTER = 0,
    SIMPLE_LOOPFILTER = 1
} LOOPFILTERTYPE;

Attila Nagy's avatar
Attila Nagy committed
29
30
31
32
33
34
35
#if ARCH_ARM
#define SIMD_WIDTH 1
#else
#define SIMD_WIDTH 16
#endif

/* Need to align this structure so when it is declared and
36
37
 * passed it can be loaded into vector registers.
 */
John Koleszar's avatar
John Koleszar committed
38
39
typedef struct
{
Attila Nagy's avatar
Attila Nagy committed
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
    DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
    DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, blim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
    DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
    DECLARE_ALIGNED(SIMD_WIDTH, unsigned char, hev_thr[4][SIMD_WIDTH]);
    unsigned char lvl[4][4][4];
    unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
    unsigned char mode_lf_lut[10];
} loop_filter_info_n;

typedef struct
{
    const unsigned char * mblim;
    const unsigned char * blim;
    const unsigned char * lim;
    const unsigned char * hev_thr;
John Koleszar's avatar
John Koleszar committed
55
56
57
58
} loop_filter_info;


#define prototype_loopfilter(sym) \
Attila Nagy's avatar
Attila Nagy committed
59
60
    void sym(unsigned char *src, int pitch, const unsigned char *blimit,\
             const unsigned char *limit, const unsigned char *thresh, int count)
John Koleszar's avatar
John Koleszar committed
61
62

#define prototype_loopfilter_block(sym) \
Attila Nagy's avatar
Attila Nagy committed
63
    void sym(unsigned char *y, unsigned char *u, unsigned char *v, \
Johann's avatar
Johann committed
64
             int ystride, int uv_stride, loop_filter_info *lfi)
John Koleszar's avatar
John Koleszar committed
65

Attila Nagy's avatar
Attila Nagy committed
66
67
68
#define prototype_simple_loopfilter(sym) \
    void sym(unsigned char *y, int ystride, const unsigned char *blimit)

John Koleszar's avatar
John Koleszar committed
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#if ARCH_X86 || ARCH_X86_64
#include "x86/loopfilter_x86.h"
#endif

#if ARCH_ARM
#include "arm/loopfilter_arm.h"
#endif

#ifndef vp8_lf_normal_mb_v
#define vp8_lf_normal_mb_v vp8_loop_filter_mbv_c
#endif
extern prototype_loopfilter_block(vp8_lf_normal_mb_v);

#ifndef vp8_lf_normal_b_v
#define vp8_lf_normal_b_v vp8_loop_filter_bv_c
#endif
extern prototype_loopfilter_block(vp8_lf_normal_b_v);

#ifndef vp8_lf_normal_mb_h
#define vp8_lf_normal_mb_h vp8_loop_filter_mbh_c
#endif
extern prototype_loopfilter_block(vp8_lf_normal_mb_h);

#ifndef vp8_lf_normal_b_h
#define vp8_lf_normal_b_h vp8_loop_filter_bh_c
#endif
extern prototype_loopfilter_block(vp8_lf_normal_b_h);

#ifndef vp8_lf_simple_mb_v
Attila Nagy's avatar
Attila Nagy committed
98
#define vp8_lf_simple_mb_v vp8_loop_filter_simple_vertical_edge_c
John Koleszar's avatar
John Koleszar committed
99
#endif
Attila Nagy's avatar
Attila Nagy committed
100
extern prototype_simple_loopfilter(vp8_lf_simple_mb_v);
John Koleszar's avatar
John Koleszar committed
101
102
103
104

#ifndef vp8_lf_simple_b_v
#define vp8_lf_simple_b_v vp8_loop_filter_bvs_c
#endif
Attila Nagy's avatar
Attila Nagy committed
105
extern prototype_simple_loopfilter(vp8_lf_simple_b_v);
John Koleszar's avatar
John Koleszar committed
106
107

#ifndef vp8_lf_simple_mb_h
Attila Nagy's avatar
Attila Nagy committed
108
#define vp8_lf_simple_mb_h vp8_loop_filter_simple_horizontal_edge_c
John Koleszar's avatar
John Koleszar committed
109
#endif
Attila Nagy's avatar
Attila Nagy committed
110
extern prototype_simple_loopfilter(vp8_lf_simple_mb_h);
John Koleszar's avatar
John Koleszar committed
111
112
113
114

#ifndef vp8_lf_simple_b_h
#define vp8_lf_simple_b_h vp8_loop_filter_bhs_c
#endif
Attila Nagy's avatar
Attila Nagy committed
115
extern prototype_simple_loopfilter(vp8_lf_simple_b_h);
John Koleszar's avatar
John Koleszar committed
116
117

typedef prototype_loopfilter_block((*vp8_lf_block_fn_t));
Attila Nagy's avatar
Attila Nagy committed
118
119
typedef prototype_simple_loopfilter((*vp8_slf_block_fn_t));

John Koleszar's avatar
John Koleszar committed
120
121
122
123
124
125
typedef struct
{
    vp8_lf_block_fn_t  normal_mb_v;
    vp8_lf_block_fn_t  normal_b_v;
    vp8_lf_block_fn_t  normal_mb_h;
    vp8_lf_block_fn_t  normal_b_h;
Attila Nagy's avatar
Attila Nagy committed
126
127
128
129
    vp8_slf_block_fn_t  simple_mb_v;
    vp8_slf_block_fn_t  simple_b_v;
    vp8_slf_block_fn_t  simple_mb_h;
    vp8_slf_block_fn_t  simple_b_h;
John Koleszar's avatar
John Koleszar committed
130
131
132
133
134
135
136
137
} vp8_loopfilter_rtcd_vtable_t;

#if CONFIG_RUNTIME_CPU_DETECT
#define LF_INVOKE(ctx,fn) (ctx)->fn
#else
#define LF_INVOKE(ctx,fn) vp8_lf_##fn
#endif

138
139
typedef void loop_filter_uvfunction
(
140
141
    unsigned char *u,   /* source pointer */
    int p,              /* pitch */
Attila Nagy's avatar
Attila Nagy committed
142
143
144
    const unsigned char *blimit,
    const unsigned char *limit,
    const unsigned char *thresh,
145
146
    unsigned char *v
);
John Koleszar's avatar
John Koleszar committed
147

Johann's avatar
Johann committed
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* assorted loopfilter functions which get used elsewhere */
struct VP8Common;
struct MacroBlockD;

void vp8_loop_filter_init(struct VP8Common *cm);

void vp8_loop_filter_frame_init(struct VP8Common *cm,
                                struct MacroBlockD *mbd,
                                int default_filt_lvl);

void vp8_loop_filter_frame(struct VP8Common *cm, struct MacroBlockD *mbd);

void vp8_loop_filter_partial_frame(struct VP8Common *cm,
                                   struct MacroBlockD *mbd,
                                   int default_filt_lvl);

void vp8_loop_filter_frame_yonly(struct VP8Common *cm,
                                 struct MacroBlockD *mbd,
                                 int default_filt_lvl);

void vp8_loop_filter_update_sharpness(loop_filter_info_n *lfi,
                                      int sharpness_lvl);

John Koleszar's avatar
John Koleszar committed
171
#endif