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
22extern "C" {
23#endif
24
25#define MAX_LOOP_FILTER 63
26#define MAX_SHARPNESS 7
27
28#define SIMD_WIDTH 16
29
30enum lf_path {
31 LF_PATH_420,
32 LF_PATH_444,
33 LF_PATH_SLOW,
34};
35
37enum { VERT_EDGE = 0, HORZ_EDGE = 1, NUM_EDGE_DIRS } UENUM1BYTE(EDGE_DIR);
38typedef struct {
39 uint64_t bits[4];
40} FilterMask;
41
42struct 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.
62typedef 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
68typedef 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
73typedef struct AV1_DEBLOCKING_PARAMETERS {
74 // length of the filter applied to the outer edge
75 uint8_t filter_length;
76 // deblocking limits
77 const loop_filter_thresh *lfthr;
78} AV1_DEBLOCKING_PARAMETERS;
79
80typedef struct LoopFilterWorkerData {
81 YV12_BUFFER_CONFIG *frame_buffer;
82 struct AV1Common *cm;
83 struct macroblockd_plane planes[MAX_MB_PLANE];
84 // TODO(Ranjit): When the filter functions are modified to use xd->lossless
85 // add lossless as a member here.
86 MACROBLOCKD *xd;
87
88 AV1_DEBLOCKING_PARAMETERS params_buf[MAX_MIB_SIZE];
89 TX_SIZE tx_buf[MAX_MIB_SIZE];
90} LFWorkerData;
93/* assorted loopfilter functions which get used elsewhere */
94struct AV1Common;
95struct macroblockd;
96struct AV1LfSyncData;
97
98void av1_loop_filter_init(struct AV1Common *cm);
99
100void av1_loop_filter_frame_init(struct AV1Common *cm, int plane_start,
101 int plane_end);
102
103void av1_filter_block_plane_vert(const struct AV1Common *const cm,
104 const MACROBLOCKD *const xd, const int plane,
105 const MACROBLOCKD_PLANE *const plane_ptr,
106 const uint32_t mi_row, const uint32_t mi_col);
107
108void av1_filter_block_plane_horz(const struct AV1Common *const cm,
109 const MACROBLOCKD *const xd, const int plane,
110 const MACROBLOCKD_PLANE *const plane_ptr,
111 const uint32_t mi_row, const uint32_t mi_col);
112
113void av1_filter_block_plane_vert_opt(const struct AV1Common *const cm,
114 const MACROBLOCKD *const xd,
115 const MACROBLOCKD_PLANE *const plane_ptr,
116 const uint32_t mi_row,
117 const uint32_t mi_col,
118 AV1_DEBLOCKING_PARAMETERS *params_buf,
119 TX_SIZE *tx_buf);
120
121void av1_filter_block_plane_vert_opt_chroma(
122 const struct AV1Common *const cm, const MACROBLOCKD *const xd,
123 const MACROBLOCKD_PLANE *const plane_ptr, const uint32_t mi_row,
124 const uint32_t mi_col, AV1_DEBLOCKING_PARAMETERS *params_buf,
125 TX_SIZE *tx_buf, int plane, bool joint_filter_chroma);
126
127void av1_filter_block_plane_horz_opt(const struct AV1Common *const cm,
128 const MACROBLOCKD *const xd,
129 const MACROBLOCKD_PLANE *const plane_ptr,
130 const uint32_t mi_row,
131 const uint32_t mi_col,
132 AV1_DEBLOCKING_PARAMETERS *params_buf,
133 TX_SIZE *tx_buf);
134
135void av1_filter_block_plane_horz_opt_chroma(
136 const struct AV1Common *const cm, const MACROBLOCKD *const xd,
137 const MACROBLOCKD_PLANE *const plane_ptr, const uint32_t mi_row,
138 const uint32_t mi_col, AV1_DEBLOCKING_PARAMETERS *params_buf,
139 TX_SIZE *tx_buf, int plane, bool joint_filter_chroma);
140
141uint8_t av1_get_filter_level(const struct AV1Common *cm,
142 const loop_filter_info_n *lfi_n, const int dir_idx,
143 int plane, const MB_MODE_INFO *mbmi);
144
145#ifdef __cplusplus
146} // extern "C"
147#endif
148
149#endif // AOM_AV1_COMMON_AV1_LOOPFILTER_H_
Top level common structure used by both encoder and decoder.
Definition: av1_common_int.h:750
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