AOMedia AV1 Codec
pickrst.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#ifndef AOM_AV1_ENCODER_PICKRST_H_
12#define AOM_AV1_ENCODER_PICKRST_H_
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#include "av1/encoder/encoder.h"
19
21struct AV1_COMP;
22
23// Enable extra debugging for loop restoration costing?
24//
25// If this is set to 1, then we record not just the selected LR parameters, but
26// also the values which the search process thinks they should be delta-coded
27// against. Then, when writing out the bitstream, we verify this information,
28// to help ensure that the search code is costing things properly
29#define DEBUG_LR_COSTING 0
30
31#if DEBUG_LR_COSTING
32#define MAX_LR_UNITS_W 64
33#define MAX_LR_UNITS_H 64
34
35// Storage for reference parameters.
36//
37// The storage size is determined by:
38// * This is always written and then checked within the same frame encode pass,
39// so we do not need to buffer multiple frames of data
40// * The parameters can be different per plane within one frame
41// * The relevant set of ref parameters can differ between the search where
42// we set the frame restoration mode to RESTORE_WIENER, and the search where
43// we set it to RESTORE_SWITCHABLE.
44// So we need to store at least two sets of Wiener params and two sets of
45// SGR params, and the easiest way to do this is to index by
46// frame_restoration_type
47extern RestorationUnitInfo lr_ref_params[RESTORE_TYPES][MAX_MB_PLANE]
48 [MAX_LR_UNITS_W * MAX_LR_UNITS_H];
49#endif // DEBUG_LR_COSTING
50
51static const uint8_t g_shuffle_stats_data[16] = {
52 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
53};
54
55static const uint8_t g_shuffle_stats_highbd_data[32] = {
56 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
57 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
58};
59
60static inline uint8_t find_average(const uint8_t *src, int h_start, int h_end,
61 int v_start, int v_end, int stride) {
62 uint64_t sum = 0;
63 for (int i = v_start; i < v_end; i++) {
64 for (int j = h_start; j < h_end; j++) {
65 sum += src[i * stride + j];
66 }
67 }
68 uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
69 return (uint8_t)avg;
70}
71
72#if CONFIG_AV1_HIGHBITDEPTH
73static inline uint16_t find_average_highbd(const uint16_t *src, int h_start,
74 int h_end, int v_start, int v_end,
75 int stride) {
76 uint64_t sum = 0;
77 for (int i = v_start; i < v_end; i++) {
78 for (int j = h_start; j < h_end; j++) {
79 sum += src[i * stride + j];
80 }
81 }
82 uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
83 return (uint16_t)avg;
84}
85#endif
86
121
122#ifdef __cplusplus
123} // extern "C"
124#endif
125
126#endif // AOM_AV1_ENCODER_PICKRST_H_
Declares top-level encoder structures and functions.
@ RESTORE_TYPES
Definition enums.h:615
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi)
Algorithm for AV1 loop restoration search and estimation.
Top level encoder structure.
Definition encoder.h:2870
Parameters related to Restoration Unit Info.
Definition restoration.h:190
YV12 frame buffer data structure.
Definition yv12config.h:46