Arxiv:1602.05975V3 [Cs.MM] 28 Oct 2017 CDEF Works by Identifying the Direction [4] of Each Block Ed = (Xp − Μd,K)
Total Page:16
File Type:pdf, Size:1020Kb
THE AV1 CONSTRAINED DIRECTIONAL ENHANCEMENT FILTER (CDEF) Steinar Midtskogen Jean-Marc Valin Cisco Systems Inc. Mozilla Corporation Lysaker, Norway Mountain View, CA, USA [email protected] [email protected] 0 1 2 3 4 5 6 7 0 0 1 1 2 2 3 3 0 0 0 0 0 0 0 0 3 3 2 2 1 1 0 0 ABSTRACT 1 2 3 4 5 6 7 8 1 1 2 2 3 3 4 4 1 1 1 1 1 1 1 1 4 4 3 3 2 2 1 1 2 3 4 5 6 7 8 9 2 2 3 3 4 4 5 5 2 2 2 2 2 2 2 2 5 5 4 4 3 3 2 2 This paper presents the constrained directional enhancement filter 3 4 5 6 7 8 9 10 3 3 4 4 5 5 6 6 3 3 3 3 3 3 3 3 6 6 5 5 4 4 3 3 4 5 6 7 8 9 10 11 4 4 5 5 6 6 7 7 4 4 4 4 4 4 4 4 7 7 6 6 5 5 4 4 designed for the AV1 royalty-free video codec. The in-loop filter 5 6 7 8 9 10 11 12 5 5 6 6 7 7 8 8 5 5 5 5 5 5 5 5 8 8 7 7 6 6 5 5 is based on a non-linear low-pass filter and is designed for vector- 6 7 8 9 10 11 12 13 6 6 7 7 8 8 9 9 6 6 6 6 6 6 6 6 9 9 8 8 7 7 6 6 7 8 9 10 11 12 13 14 7 7 8 8 9 9 10 10 7 7 7 7 7 7 7 7 10 10 9 9 8 8 7 7 ization efficiency. It takes into account the direction of edges and d = 0 d = 1 d = 2 d = 3 patterns being filtered. The filter works by identifying the direc- 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 tion of each block and then adaptively filtering with a high degree 8 7 6 5 4 3 2 1 7 6 5 4 3 2 1 0 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 of control over the filter strength along the direction and across it. 9 8 7 6 5 4 3 2 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 10 9 8 7 6 5 4 3 8 7 6 5 4 3 2 1 0 1 2 3 4 5 6 7 1 2 3 4 5 6 7 8 The proposed enhancement filter is shown to improve the quality of 11 10 9 8 7 6 5 4 9 8 7 6 5 4 3 2 0 1 2 3 4 5 6 7 2 3 4 5 6 7 8 9 the Alliance for Open Media (AOM) AV1 and Thor video codecs in 12 11 10 9 8 7 6 5 9 8 7 6 5 4 3 2 0 1 2 3 4 5 6 7 2 3 4 5 6 7 8 9 13 12 11 10 9 8 7 6 10 9 8 7 6 5 4 3 0 1 2 3 4 5 6 7 3 4 5 6 7 8 9 10 particular in low complexity configurations. 14 13 12 11 10 9 8 7 10 9 8 7 6 5 4 3 0 1 2 3 4 5 6 7 3 4 5 6 7 8 9 10 Index Terms— enhancement filter, directional filter, AV1 d = 4 d = 5 d = 6 d = 7 Fig. 1. Line number k for pixels following direction d = 0 : 7 in 1. INTRODUCTION an 8 × 8 block. The main goal of the in-loop constrained directional enhancement filter (CDEF) is to filter out coding artifacts while retaining the For each block we determine the direction that best matches the details of the image. In HEVC [1], the Sample Adaptive Off- pattern in the block by minimizing the sum of squared differences set (SAO) [2] algorithm achieves a similar goal by defining signal (SSD) between the quantized block and the closest perfectly direc- offsets for different classes of pixels. Unlike SAO, the approach tional block. A perfectly directional block is a block where all of we take in AV1 is that of a non-linear spatial filter. From the very the pixels along a line in one direction have the same value. For beginning, the design of the filter was constrained to be easily vec- each direction, we assign a line number k to each pixel, as shown in torizable (i.e. implementable with SIMD operations), which was Fig.1. not the case for other non-linear filters like the median filter and the For each direction d, the pixel average for line k is bilateral filter [3]. 1 X µd;k = xp ; (1) The CDEF design originates from the following observations. Nd;k The amount of ringing artifacts in a coded image tends to be roughly p2Pd;k proportional to the quantization step size. The amount of detail is a where xp is the value of pixel p, Pd;k is the set of pixels in line k fol- property of the input image, but the smallest detail actually retained lowing direction d and Nd;k is the cardinality of Pd;k (for example, in the quantized image tends to also be proportional to the quanti- in Fig.1, N1;0 = 2 and N1;4 = 8). The SSD is then zation step size. For a given quantization step size, the amplitude of 2 3 the ringing is generally less than the amplitude of the details. 2 X X 2 arXiv:1602.05975v3 [cs.MM] 28 Oct 2017 CDEF works by identifying the direction [4] of each block Ed = 4 (xp − µd;k) 5 : (2) (Sec.2) and then adaptively filtering along the identified direction k p2Pd;k (Sec.3) and to a lesser degree along directions rotated 45 degrees Substituting (1) into (2) and simplifying results in from the identified direction. The filter strengths are signaled ex- 2 plicitly, which allows a high degree of control over the blurring 0 1 2 X 2 X 1 X (Sec.4). Sec.5 demonstrates an efficient encoder search for the Ed = xp − @ xpA : (3) Nd;k filter strengths, with results presented in Sec.6. p k p2Pd;k Note that the simplifications leading to (3) are the same as to those 2. DIRECTION SEARCH 2 P x2 (P x)2 allowing a variance to be computed as σx = N − N2 . Con- sidering that the first term of (3) is constant with respect to d, we The direction search operates on the reconstructed pixels, just after find the optimal direction dopt by maximizing the second term: the deblocking filter. Since those pixels are available to the de- dopt = max sd (4) coder, the directions require no signaling. The search operates on d 8 × 8 blocks, which are small enough to adequately handle non- 0 12 straight edges, while being large enough to reliably estimate direc- X 1 X sd = @ xpA : (5) tions when applied to a quantized image. Having a constant direc- Nd;k tion over an 8×8 region also makes vectorization of the filter easier. k p2Pd;k Initialize all variables to zero for d = 0 to 7 do for i = 0 to 7 do for j = 0 to 7 do L line_table[d][i][j] partial[d][L] partial[d][L] + (pixel[i][j] − 128) count[d][L] count[d][L] + 1 end for end for for L = 0 to 14 do if count[d][L] > 0 then s[d] s[d] + partial[d][L]2 · 840=count[d][L] Fig. 2. Example of direction search for an 8×8 block. The patterns end if shown are based on the µd;k values. In this case, the 45-degree 2 end for direction is selected because it minimizes Ed . The error values Ed shown are never computed in practice (only s is). end for d for d = 0 to 7 do if s[d] > s[best_d] then best_d d We can avoid the division in (5) by multiplying sd by 840, the end if least common multiple of the possible Nd;k values (1 ≤ Nd;k ≤ end for 8). When using 8-bit pixel data, and centering the values such that direction best_d −128 ≤ xp ≤ 127, then 840sd and all calculations needed for sd directional_contrast s[best_d]−s[(best_d+4) mod 8] fit in a 32-bit signed integer. For higher bit depths, we downscale the pixels to 8 bits during the direction search. Algorithm 1: Direction search. The line_table[d][i][j] values are Fig.2 shows an example of a direction search for an 8 × 8 the line numbers shown in Fig.1. The 840=count[d][L] terms can block containing a line. The step-by-step process is described in al- be pre-computed. More functionally equivalent algebraic simplifi- gorithm1. To save on decoder complexity, we assume that luma and cations are possible, but they are not shown here for clarity. chroma directions are correlated, and only search the luma compo- nent.