Line data Source code
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 AV1_ENCODER_PICKRST_H_
12 : #define AV1_ENCODER_PICKRST_H_
13 :
14 : #ifdef __cplusplus
15 : extern "C" {
16 : #endif
17 :
18 : #include "EbDefinitions.h"
19 : #include "EbPictureBufferDesc.h"
20 :
21 : struct Yv12BufferConfig;
22 : struct Av1Comp;
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 0 : static INLINE uint8_t find_average(const uint8_t *src, int32_t h_start, int32_t h_end,
34 : int32_t v_start, int32_t v_end, int32_t stride) {
35 0 : uint64_t sum = 0;
36 0 : for (int32_t i = v_start; i < v_end; i++) {
37 0 : for (int32_t j = h_start; j < h_end; j++)
38 0 : sum += src[i * stride + j];
39 : }
40 0 : uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
41 0 : return (uint8_t)avg;
42 : }
43 :
44 0 : static INLINE uint16_t find_average_highbd(const uint16_t *src, int32_t h_start,
45 : int32_t h_end, int32_t v_start, int32_t v_end,
46 : int32_t stride) {
47 0 : uint64_t sum = 0;
48 0 : for (int32_t i = v_start; i < v_end; i++) {
49 0 : for (int32_t j = h_start; j < h_end; j++)
50 0 : sum += src[i * stride + j];
51 : }
52 0 : uint64_t avg = sum / ((v_end - v_start) * (h_end - h_start));
53 0 : return (uint16_t)avg;
54 : }
55 :
56 : #ifdef __cplusplus
57 : } // extern "C"
58 : #endif
59 :
60 : #endif // AV1_ENCODER_PICKRST_H_
|