Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 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. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_COMMON_QUANT_COMMON_H_ |
| 13 | #define AOM_AV1_COMMON_QUANT_COMMON_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 15 | #include "aom/aom_codec.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 16 | #include "av1/common/seg_common.h" |
| 17 | #include "av1/common/enums.h" |
Debargha Mukherjee | 3c42c09 | 2016-09-29 09:17:36 -0700 | [diff] [blame] | 18 | #include "av1/common/entropy.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | #define MINQ 0 |
| 25 | #define MAXQ 255 |
| 26 | #define QINDEX_RANGE (MAXQ - MINQ + 1) |
| 27 | #define QINDEX_BITS 8 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | // Total number of QM sets stored |
| 29 | #define QM_LEVEL_BITS 4 |
| 30 | #define NUM_QM_LEVELS (1 << QM_LEVEL_BITS) |
Thomas Davies | 6675adf | 2017-05-04 17:39:21 +0100 | [diff] [blame] | 31 | /* Range of QMS is between first and last value, with offset applied to inter |
| 32 | * blocks*/ |
Yaowu Xu | f7a1242 | 2018-01-31 15:29:20 -0800 | [diff] [blame] | 33 | #define DEFAULT_QM_Y 10 |
| 34 | #define DEFAULT_QM_U 11 |
| 35 | #define DEFAULT_QM_V 12 |
Thomas Davies | 6675adf | 2017-05-04 17:39:21 +0100 | [diff] [blame] | 36 | #define DEFAULT_QM_FIRST 5 |
| 37 | #define DEFAULT_QM_LAST 9 |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 38 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 39 | struct AV1Common; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 40 | |
Monty Montgomery | 60f2a22 | 2017-11-01 19:48:38 -0400 | [diff] [blame] | 41 | int16_t av1_dc_quant_Q3(int qindex, int delta, aom_bit_depth_t bit_depth); |
| 42 | int16_t av1_ac_quant_Q3(int qindex, int delta, aom_bit_depth_t bit_depth); |
| 43 | int16_t av1_dc_quant_QTX(int qindex, int delta, aom_bit_depth_t bit_depth); |
| 44 | int16_t av1_ac_quant_QTX(int qindex, int delta, aom_bit_depth_t bit_depth); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 45 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 46 | int av1_get_qindex(const struct segmentation *seg, int segment_id, |
| 47 | int base_qindex); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 48 | // Reduce the large number of quantizers to a smaller number of levels for which |
| 49 | // different matrices may be defined |
Debargha Mukherjee | 3c42c09 | 2016-09-29 09:17:36 -0700 | [diff] [blame] | 50 | static INLINE int aom_get_qmlevel(int qindex, int first, int last) { |
David Barker | 85d27f7 | 2017-09-14 14:44:27 +0100 | [diff] [blame] | 51 | return first + (qindex * (last + 1 - first)) / QINDEX_RANGE; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 52 | } |
Zoe Liu | d902b74 | 2018-02-19 17:02:41 -0800 | [diff] [blame] | 53 | void av1_qm_init(struct AV1Common *cm); |
| 54 | const qm_val_t *av1_iqmatrix(struct AV1Common *cm, int qindex, int comp, |
Ralph Giles | 90243cf | 2018-01-12 14:17:46 -0800 | [diff] [blame] | 55 | TX_SIZE tx_size); |
Zoe Liu | d902b74 | 2018-02-19 17:02:41 -0800 | [diff] [blame] | 56 | const qm_val_t *av1_qmatrix(struct AV1Common *cm, int qindex, int comp, |
Ralph Giles | 90243cf | 2018-01-12 14:17:46 -0800 | [diff] [blame] | 57 | TX_SIZE tx_size); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 58 | |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 59 | #ifdef __cplusplus |
| 60 | } // extern "C" |
| 61 | #endif |
| 62 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 63 | #endif // AOM_AV1_COMMON_QUANT_COMMON_H_ |