• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
find_average(const uint8_t * src,int h_start,int h_end,int v_start,int v_end,int stride)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 
find_average_highbd(const uint16_t * src,int h_start,int h_end,int v_start,int v_end,int stride)45 static INLINE uint16_t find_average_highbd(const uint16_t *src, int h_start,
46                                            int h_end, int v_start, int v_end,
47                                            int stride) {
48   uint64_t sum = 0;
49   for (int i = v_start; i < v_end; i++) {
50     for (int j = h_start; j < h_end; j++) {
51       sum += src[i * stride + j];
52     }
53   }
54   uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
55   return (uint16_t)avg;
56 }
57 
58 void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi);
59 
60 #ifdef __cplusplus
61 }  // extern "C"
62 #endif
63 
64 #endif  // AOM_AV1_ENCODER_PICKRST_H_
65