Merge "Skip computation of distortion in vp8_pick_inter_mode if active_map is used"
[libvpx.git] / vp8 / common / quant_common.c
blobe9833fe33b4aa658c855a490842c8deb5a6103e7
1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
12 #include "quant_common.h"
14 static const int dc_qlookup[QINDEX_RANGE] =
16 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17,
17 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28,
18 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43,
19 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
20 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
21 75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
22 91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118,
23 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157,
26 static const int ac_qlookup[QINDEX_RANGE] =
28 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
29 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
30 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
31 52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76,
32 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108,
33 110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152,
34 155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209,
35 213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284,
39 int vp8_dc_quant(int QIndex, int Delta)
41 int retval;
43 QIndex = QIndex + Delta;
45 if (QIndex > 127)
46 QIndex = 127;
47 else if (QIndex < 0)
48 QIndex = 0;
50 retval = dc_qlookup[ QIndex ];
51 return retval;
54 int vp8_dc2quant(int QIndex, int Delta)
56 int retval;
58 QIndex = QIndex + Delta;
60 if (QIndex > 127)
61 QIndex = 127;
62 else if (QIndex < 0)
63 QIndex = 0;
65 retval = dc_qlookup[ QIndex ] * 2;
66 return retval;
69 int vp8_dc_uv_quant(int QIndex, int Delta)
71 int retval;
73 QIndex = QIndex + Delta;
75 if (QIndex > 127)
76 QIndex = 127;
77 else if (QIndex < 0)
78 QIndex = 0;
80 retval = dc_qlookup[ QIndex ];
82 if (retval > 132)
83 retval = 132;
85 return retval;
88 int vp8_ac_yquant(int QIndex)
90 int retval;
92 if (QIndex > 127)
93 QIndex = 127;
94 else if (QIndex < 0)
95 QIndex = 0;
97 retval = ac_qlookup[ QIndex ];
98 return retval;
101 int vp8_ac2quant(int QIndex, int Delta)
103 int retval;
105 QIndex = QIndex + Delta;
107 if (QIndex > 127)
108 QIndex = 127;
109 else if (QIndex < 0)
110 QIndex = 0;
112 retval = (ac_qlookup[ QIndex ] * 155) / 100;
114 if (retval < 8)
115 retval = 8;
117 return retval;
119 int vp8_ac_uv_quant(int QIndex, int Delta)
121 int retval;
123 QIndex = QIndex + Delta;
125 if (QIndex > 127)
126 QIndex = 127;
127 else if (QIndex < 0)
128 QIndex = 0;
130 retval = ac_qlookup[ QIndex ];
131 return retval;