pickrst.h
/*
* 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_PICKRST_H_
#define AOM_AV1_ENCODER_PICKRST_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "av1/encoder/encoder.h"
struct yv12_buffer_config;
struct AV1_COMP;
// Enable extra debugging for loop restoration costing?
//
// If this is set to 1, then we record not just the selected LR parameters, but
// also the values which the search process thinks they should be delta-coded
// against. Then, when writing out the bitstream, we verify this information,
// to help ensure that the search code is costing things properly
#define DEBUG_LR_COSTING 0
#if DEBUG_LR_COSTING
#define MAX_LR_UNITS_W 64
#define MAX_LR_UNITS_H 64
// Storage for reference parameters.
//
// The storage size is determined by:
// * This is always written and then checked within the same frame encode pass,
// so we do not need to buffer multiple frames of data
// * The parameters can be different per plane within one frame
// * The relevant set of ref parameters can differ between the search where
// we set the frame restoration mode to RESTORE_WIENER, and the search where
// we set it to RESTORE_SWITCHABLE.
// So we need to store at least two sets of Wiener params and two sets of
// SGR params, and the easiest way to do this is to index by
// frame_restoration_type
extern RestorationUnitInfo lr_ref_params[RESTORE_TYPES][MAX_MB_PLANE]
[MAX_LR_UNITS_W * MAX_LR_UNITS_H];
#endif // DEBUG_LR_COSTING
static const uint8_t g_shuffle_stats_data[16] = {
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
};
static const uint8_t g_shuffle_stats_highbd_data[32] = {
0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
};
static inline uint8_t find_average(const uint8_t *src, int h_start, int h_end,
int v_start, int v_end, int stride) {
uint64_t sum = 0;
for (int i = v_start; i < v_end; i++) {
for (int j = h_start; j < h_end; j++) {
sum += src[i * stride + j];
}
}
uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
return (uint8_t)avg;
}
#if CONFIG_AV1_HIGHBITDEPTH
static inline uint16_t find_average_highbd(const uint16_t *src, int h_start,
int h_end, int v_start, int v_end,
int stride) {
uint64_t sum = 0;
for (int i = v_start; i < v_end; i++) {
for (int j = h_start; j < h_end; j++) {
sum += src[i * stride + j];
}
}
uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
return (uint16_t)avg;
}
#endif
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AV1_ENCODER_PICKRST_H_
encoder.h
Declares top-level encoder structures and functions.
RESTORE_TYPES
@ RESTORE_TYPES
Definition enums.h:615
av1_pick_filter_restoration
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi)
Algorithm for AV1 loop restoration search and estimation.
AV1_COMP
Top level encoder structure.
Definition encoder.h:2897
RestorationUnitInfo
Parameters related to Restoration Unit Info.
Definition restoration.h:190
yv12_buffer_config
YV12 frame buffer data structure.
Definition yv12config.h:46