vp9_loopfilter.h 3.06 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"
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 21 22 23
#ifdef __cplusplus
extern "C" {
#endif

John Koleszar's avatar
John Koleszar committed
24
#define MAX_LOOP_FILTER 63
Dmitry Kovalev's avatar
Dmitry Kovalev committed
25 26
#define MAX_SHARPNESS 7

Attila Nagy's avatar
Attila Nagy committed
27 28
#define SIMD_WIDTH 16

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#define MAX_REF_LF_DELTAS       4
#define MAX_MODE_LF_DELTAS      2

struct loopfilter {
  int filter_level;

  int sharpness_level;
  int last_sharpness_level;

  uint8_t mode_ref_delta_enabled;
  uint8_t mode_ref_delta_update;

  // 0 = Intra, Last, GF, ARF
  signed char ref_deltas[MAX_REF_LF_DELTAS];
  signed char last_ref_deltas[MAX_REF_LF_DELTAS];

  // 0 = ZERO_MV, MV
  signed char mode_deltas[MAX_MODE_LF_DELTAS];
  signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
};

Dmitry Kovalev's avatar
Dmitry Kovalev committed
50 51
// 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
52
typedef struct {
53 54 55 56 57 58 59
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, mblim[SIMD_WIDTH]);
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, lim[SIMD_WIDTH]);
  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, hev_thr[SIMD_WIDTH]);
} loop_filter_thresh;

typedef struct {
  loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
Paul Wilkins's avatar
Paul Wilkins committed
60
  uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
Attila Nagy's avatar
Attila Nagy committed
61 62
} loop_filter_info_n;

Johann's avatar
Johann committed
63
/* assorted loopfilter functions which get used elsewhere */
64
struct VP9Common;
Jim Bankoski's avatar
Jim Bankoski committed
65
struct macroblockd;
Johann's avatar
Johann committed
66

67
void vp9_loop_filter_init(struct VP9Common *cm);
Johann's avatar
Johann committed
68

69 70 71
// 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.
72
void vp9_loop_filter_frame_init(struct VP9Common *cm, int default_filt_lvl);
73

74 75 76
void vp9_loop_filter_frame(struct VP9Common *cm,
                           struct macroblockd *mbd,
                           int filter_level,
77
                           int y_only, int partial);
78 79 80 81 82

// 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);
83 84 85 86 87 88 89 90 91 92 93 94 95 96

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);
97 98 99 100
#ifdef __cplusplus
}  // extern "C"
#endif

101
#endif  // VP9_COMMON_VP9_LOOPFILTER_H_