AOMedia AV1 Codec
av1_loopfilter.h
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_COMMON_AV1_LOOPFILTER_H_
13 #define AOM_AV1_COMMON_AV1_LOOPFILTER_H_
14 
15 #include "config/aom_config.h"
16 
17 #include "aom_ports/mem.h"
18 #include "av1/common/blockd.h"
19 #include "av1/common/seg_common.h"
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 #define MAX_LOOP_FILTER 63
26 #define MAX_SHARPNESS 7
27 
28 #define SIMD_WIDTH 16
29 
30 enum lf_path {
31  LF_PATH_420,
32  LF_PATH_444,
33  LF_PATH_SLOW,
34 };
35 
37 enum { VERT_EDGE = 0, HORZ_EDGE = 1, NUM_EDGE_DIRS } UENUM1BYTE(EDGE_DIR);
38 typedef struct {
39  uint64_t bits[4];
40 } FilterMask;
41 
42 struct loopfilter {
43  int filter_level[2];
44  int filter_level_u;
45  int filter_level_v;
46 
47  int sharpness_level;
48 
49  uint8_t mode_ref_delta_enabled;
50  uint8_t mode_ref_delta_update;
51 
52  // 0 = Intra, Last, Last2+Last3,
53  // GF, BRF, ARF2, ARF
54  int8_t ref_deltas[REF_FRAMES];
55 
56  // 0 = ZERO_MV, MV
57  int8_t mode_deltas[MAX_MODE_LF_DELTAS];
58 };
59 
60 // Need to align this structure so when it is declared and
61 // passed it can be loaded into vector registers.
62 typedef struct {
63  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, mblim[SIMD_WIDTH]);
64  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, lim[SIMD_WIDTH]);
65  DECLARE_ALIGNED(SIMD_WIDTH, uint8_t, hev_thr[SIMD_WIDTH]);
66 } loop_filter_thresh;
67 
68 typedef struct {
69  loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
70  uint8_t lvl[MAX_MB_PLANE][MAX_SEGMENTS][2][REF_FRAMES][MAX_MODE_LF_DELTAS];
71 } loop_filter_info_n;
72 
73 typedef struct LoopFilterWorkerData {
74  YV12_BUFFER_CONFIG *frame_buffer;
75  struct AV1Common *cm;
76  struct macroblockd_plane planes[MAX_MB_PLANE];
77  // TODO(Ranjit): When the filter functions are modified to use xd->lossless
78  // add lossless as a member here.
79  MACROBLOCKD *xd;
80 } LFWorkerData;
83 /* assorted loopfilter functions which get used elsewhere */
84 struct AV1Common;
85 struct macroblockd;
86 struct AV1LfSyncData;
87 
88 void av1_loop_filter_init(struct AV1Common *cm);
89 
90 void av1_loop_filter_frame_init(struct AV1Common *cm, int plane_start,
91  int plane_end);
92 
93 void av1_filter_block_plane_vert(const struct AV1Common *const cm,
94  const MACROBLOCKD *const xd, const int plane,
95  const MACROBLOCKD_PLANE *const plane_ptr,
96  const uint32_t mi_row, const uint32_t mi_col);
97 
98 void av1_filter_block_plane_horz(const struct AV1Common *const cm,
99  const MACROBLOCKD *const xd, const int plane,
100  const MACROBLOCKD_PLANE *const plane_ptr,
101  const uint32_t mi_row, const uint32_t mi_col);
102 
103 void av1_filter_block_plane_vert_rt(const struct AV1Common *const cm,
104  const MACROBLOCKD *const xd,
105  const int plane,
106  const MACROBLOCKD_PLANE *const plane_ptr,
107  const uint32_t mi_row,
108  const uint32_t mi_col);
109 
110 void av1_filter_block_plane_horz_rt(const struct AV1Common *const cm,
111  const MACROBLOCKD *const xd,
112  const int plane,
113  const MACROBLOCKD_PLANE *const plane_ptr,
114  const uint32_t mi_row,
115  const uint32_t mi_col);
116 
117 uint8_t av1_get_filter_level(const struct AV1Common *cm,
118  const loop_filter_info_n *lfi_n, const int dir_idx,
119  int plane, const MB_MODE_INFO *mbmi);
120 
121 #ifdef __cplusplus
122 } // extern "C"
123 #endif
124 
125 #endif // AOM_AV1_COMMON_AV1_LOOPFILTER_H_
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:755
Stores the prediction/txfm mode of the current coding block.
Definition: blockd.h:222
Variables related to current coding block.
Definition: blockd.h:577
YV12 frame buffer data structure.
Definition: yv12config.h:39