vp9_loopfilter.h 3.77 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
#ifndef VP9_COMMON_VP9_LOOPFILTER_H_
#define VP9_COMMON_VP9_LOOPFILTER_H_
John Koleszar's avatar
John Koleszar committed
13
14

#include "vpx_ports/mem.h"
Attila Nagy's avatar
Attila Nagy committed
15
#include "vpx_config.h"
16
#include "vp9/common/vp9_blockd.h"
John Koleszar's avatar
John Koleszar committed
17
18
19

#define MAX_LOOP_FILTER 63

John Koleszar's avatar
John Koleszar committed
20
21
22
typedef enum {
  NORMAL_LOOPFILTER = 0,
  SIMPLE_LOOPFILTER = 1
John Koleszar's avatar
John Koleszar committed
23
24
} LOOPFILTERTYPE;

Attila Nagy's avatar
Attila Nagy committed
25
26
27
#define SIMD_WIDTH 16

/* Need to align this structure so when it is declared and
28
29
 * passed it can be loaded into vector registers.
 */
John Koleszar's avatar
John Koleszar committed
30
typedef struct {
31
32
33
34
35
36
37
38
  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]);
John Koleszar's avatar
John Koleszar committed
39
40
41
  unsigned char lvl[4][4][4];
  unsigned char hev_thr_lut[2][MAX_LOOP_FILTER + 1];
  unsigned char mode_lf_lut[MB_MODE_COUNT];
Attila Nagy's avatar
Attila Nagy committed
42
43
} loop_filter_info_n;

44
struct loop_filter_info {
John Koleszar's avatar
John Koleszar committed
45
46
47
48
  const unsigned char *mblim;
  const unsigned char *blim;
  const unsigned char *lim;
  const unsigned char *hev_thr;
49
};
John Koleszar's avatar
John Koleszar committed
50
51

#define prototype_loopfilter(sym) \
52
  void sym(uint8_t *src, int pitch, const unsigned char *blimit, \
John Koleszar's avatar
John Koleszar committed
53
           const unsigned char *limit, const unsigned char *thresh, int count)
John Koleszar's avatar
John Koleszar committed
54
55

#define prototype_loopfilter_block(sym) \
56
  void sym(uint8_t *y, uint8_t *u, uint8_t *v, \
57
           int ystride, int uv_stride, struct loop_filter_info *lfi)
John Koleszar's avatar
John Koleszar committed
58

Attila Nagy's avatar
Attila Nagy committed
59
#define prototype_simple_loopfilter(sym) \
60
  void sym(uint8_t *y, int ystride, const unsigned char *blimit)
Attila Nagy's avatar
Attila Nagy committed
61

John Koleszar's avatar
John Koleszar committed
62
#if ARCH_X86 || ARCH_X86_64
63
#include "x86/vp9_loopfilter_x86.h"
John Koleszar's avatar
John Koleszar committed
64
65
#endif

66
typedef void loop_filter_uvfunction(uint8_t *u,   /* source pointer */
67
68
69
70
                                    int p,              /* pitch */
                                    const unsigned char *blimit,
                                    const unsigned char *limit,
                                    const unsigned char *thresh,
71
                                    uint8_t *v);
John Koleszar's avatar
John Koleszar committed
72

Johann's avatar
Johann committed
73
/* assorted loopfilter functions which get used elsewhere */
74
struct VP9Common;
Jim Bankoski's avatar
Jim Bankoski committed
75
struct macroblockd;
Johann's avatar
Johann committed
76

77
void vp9_loop_filter_init(struct VP9Common *cm);
Johann's avatar
Johann committed
78

79
void vp9_loop_filter_frame_init(struct VP9Common *cm,
Jim Bankoski's avatar
Jim Bankoski committed
80
                                struct macroblockd *mbd,
Johann's avatar
Johann committed
81
82
                                int default_filt_lvl);

83
84
85
86
void vp9_loop_filter_frame(struct VP9Common *cm,
                           struct macroblockd *mbd,
                           int filter_level,
                           int y_only);
Johann's avatar
Johann committed
87

88
void vp9_loop_filter_partial_frame(struct VP9Common *cm,
Jim Bankoski's avatar
Jim Bankoski committed
89
                                   struct macroblockd *mbd,
Johann's avatar
Johann committed
90
91
                                   int default_filt_lvl);

92
void vp9_loop_filter_update_sharpness(loop_filter_info_n *lfi,
Johann's avatar
Johann committed
93
94
                                      int sharpness_lvl);

95
96
97
98
99
100
101
102
103
104
105
void vp9_mb_lpf_horizontal_edge_w(unsigned char *s, int p,
                                  const unsigned char *blimit,
                                  const unsigned char *limit,
                                  const unsigned char *thresh,
                                  int count);

void vp9_mb_lpf_vertical_edge_w(unsigned char *s, int p,
                                const unsigned char *blimit,
                                const unsigned char *limit,
                                const unsigned char *thresh,
                                int count);
106
#endif  // VP9_COMMON_VP9_LOOPFILTER_H_