vp9_loopfilter.h 2.76 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

17
#include "vp9/common/vp9_blockd.h"
18
#include "vp9/common/vp9_seg_common.h"
John Koleszar's avatar
John Koleszar committed
19 20

#define MAX_LOOP_FILTER 63
Dmitry Kovalev's avatar
Dmitry Kovalev committed
21 22
#define MAX_SHARPNESS 7

Attila Nagy's avatar
Attila Nagy committed
23 24
#define SIMD_WIDTH 16

Dmitry Kovalev's avatar
Dmitry Kovalev committed
25 26
// Need to align this structure so when it is declared and
// passed it can be loaded into vector registers.
John Koleszar's avatar
John Koleszar committed
27
typedef struct {
Dmitry Kovalev's avatar
Dmitry Kovalev committed
28
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
29
                  mblim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
30
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
31
                  lim[MAX_LOOP_FILTER + 1][SIMD_WIDTH]);
Dmitry Kovalev's avatar
Dmitry Kovalev committed
32
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t,
33
                  hev_thr[4][SIMD_WIDTH]);
Paul Wilkins's avatar
Paul Wilkins committed
34
  uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
Dmitry Kovalev's avatar
Dmitry Kovalev committed
35
  uint8_t mode_lf_lut[MB_MODE_COUNT];
Attila Nagy's avatar
Attila Nagy committed
36 37
} loop_filter_info_n;

38
struct loop_filter_info {
Dmitry Kovalev's avatar
Dmitry Kovalev committed
39 40 41
  const uint8_t *mblim;
  const uint8_t *lim;
  const uint8_t *hev_thr;
42
};
John Koleszar's avatar
John Koleszar committed
43

Dmitry Kovalev's avatar
Dmitry Kovalev committed
44

Johann's avatar
Johann committed
45
/* assorted loopfilter functions which get used elsewhere */
46
struct VP9Common;
Jim Bankoski's avatar
Jim Bankoski committed
47
struct macroblockd;
Johann's avatar
Johann committed
48

49
void vp9_loop_filter_init(struct VP9Common *cm, struct loopfilter *lf);
Johann's avatar
Johann committed
50

51 52 53 54 55 56 57
// Update the loop filter for the current frame.
// This should be called before vp9_loop_filter_rows(), vp9_loop_filter_frame()
// calls this function directly.
void vp9_loop_filter_frame_init(struct VP9Common *const cm,
                                struct macroblockd *const xd,
                                int default_filt_lvl);

58 59 60
void vp9_loop_filter_frame(struct VP9Common *cm,
                           struct macroblockd *mbd,
                           int filter_level,
Paul Wilkins's avatar
Paul Wilkins committed
61
                           int y_only);
62 63 64 65 66

// Apply the loop filter to [start, stop) macro block rows in frame_buffer.
void vp9_loop_filter_rows(const YV12_BUFFER_CONFIG *frame_buffer,
                          struct VP9Common *cm, struct macroblockd *xd,
                          int start, int stop, int y_only);
67 68 69 70 71 72 73 74 75 76 77 78 79 80

typedef struct LoopFilterWorkerData {
  const YV12_BUFFER_CONFIG *frame_buffer;
  struct VP9Common *cm;
  struct macroblockd xd;  // TODO(jzern): most of this is unnecessary to the
                          // loopfilter. the planes are necessary as their state
                          // is changed during decode.
  int start;
  int stop;
  int y_only;
} LFWorkerData;

// Operates on the rows described by LFWorkerData passed as 'arg1'.
int vp9_loop_filter_worker(void *arg1, void *arg2);
81
#endif  // VP9_COMMON_VP9_LOOPFILTER_H_