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
15 extern "C" {
16 #endif
17 
18 #include "av1/encoder/encoder.h"
19 #include "aom_ports/system_state.h"
20 
21 struct yv12_buffer_config;
22 struct AV1_COMP;
23 
24 static const uint8_t g_shuffle_stats_data[16] = {
25  0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
26 };
27 
28 static const uint8_t g_shuffle_stats_highbd_data[32] = {
29  0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
30  0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9,
31 };
32 
33 static INLINE uint8_t find_average(const uint8_t *src, int h_start, int h_end,
34  int v_start, int v_end, int stride) {
35  uint64_t sum = 0;
36  for (int i = v_start; i < v_end; i++) {
37  for (int j = h_start; j < h_end; j++) {
38  sum += src[i * stride + j];
39  }
40  }
41  uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
42  return (uint8_t)avg;
43 }
44 
45 #if CONFIG_AV1_HIGHBITDEPTH
46 static INLINE uint16_t find_average_highbd(const uint16_t *src, int h_start,
47  int h_end, int v_start, int v_end,
48  int stride) {
49  uint64_t sum = 0;
50  for (int i = v_start; i < v_end; i++) {
51  for (int j = h_start; j < h_end; j++) {
52  sum += src[i * stride + j];
53  }
54  }
55  uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
56  return (uint16_t)avg;
57 }
58 #endif
59 
94 
95 #ifdef __cplusplus
96 } // extern "C"
97 #endif
98 
99 #endif // AOM_AV1_ENCODER_PICKRST_H_
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi)
Algorithm for AV1 loop restoration search and estimation.
YV12 frame buffer data structure.
Definition: yv12config.h:38
Top level encoder structure.
Definition: encoder.h:2095
Declares top-level encoder structures and functions.