/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent. */ #ifndef AOM_AV1_ENCODER_PICKLPF_H_ #define AOM_AV1_ENCODER_PICKLPF_H_ #ifdef __cplusplus extern "C" { #endif #include "av1/encoder/encoder.h" struct yv12_buffer_config; struct AV1_COMP; int av1_get_max_filter_level(const AV1_COMP *cpi); /*!\brief Algorithm for AV1 loop filter level selection. * * \ingroup in_loop_filter * This function determines proper filter levels used for in-loop filter * (deblock filter). * * \param[in] sd The pointer of frame buffer * \param[in] cpi Top-level encoder structure * \param[in] method The method used to select filter levels * * \par * method includes: * \arg \c LPF_PICK_FROM_FULL_IMAGE: Try the full image with different values. * \arg \c LPF_PICK_FROM_FULL_IMAGE_NON_DUAL: Try the full image filter search * with non-dual filter only. * \arg \c LPF_PICK_FROM_SUBIMAGE: Try a small portion of the image with * different values. * \arg \c LPF_PICK_FROM_Q: Estimate the level based on quantizer and frame type * \arg \c LPF_PICK_MINIMAL_LPF: Pick 0 to disable LPF if LPF was enabled last * frame * * \remark Nothing is returned. Instead, filter levels below are stored in the * "loopfilter" structure inside "cpi": * \arg \c filter_level[0]: the vertical filter level for Y plane * \arg \c filter_level[1]: the horizontal filter level for Y plane * \arg \c filter_level_u: the filter level for U plane * \arg \c filter_level_v: the filter level for V plane * * \n * \b Overview * \par * The workflow of deblock filter is shown in Fig.1. \n * Boundary pixels pass through a non-flatness check, followed by a step that * determines smoothness and selects proper types of filters * (4-, 6-, 8-, 14-tap filter). \n * If non-flatness criteria is not satisfied, the encoder will not apply * deblock filtering on these boundary pixels. * \image html filter_flow.png "Fig.1. The workflow of deblock filter" width=70% * * \par * The non-flatness is determined by the boundary pixels and thresholds as shown * in Fig.2. \n * Filtering is applied when \n * \f$|p_0-p_1| 700 ? 0.04590 : 0.02295 \n * For 10 bit and 12 bit: \n * filt_guess = q * 0.316206 + 3.87252 \n * Then filter_level[0] = filter_level[1] = filter_level_u = filter_level_v = * clamp(filt_guess, min_filter_level, max_filter_level) \n * Where min_filter_level = 0, max_filter_level = 64 \n * The equations were determined by linear fitting using filter levels * generated by "LPF_PICK_FROM_FULL_IMAGE" method. * */ void av1_pick_filter_level(const struct yv12_buffer_config *sd, struct AV1_COMP *cpi, LPF_PICK_METHOD method); #ifdef __cplusplus } // extern "C" #endif #endif // AOM_AV1_ENCODER_PICKLPF_H_