5b42ae09ae
Prior to this change, VP8 min quantizer is 4, which caps the highest quality around 51DB. This experimental change extends the min quantizer to 1, removes the cap and allows the highest quality to be around ~73DB, consistent with the fdct/idct round trip error. To test this change, at configure time use options: --enable-experimental --enable-extend_qrange The following is a brief log of changes in each of the patch sets patch set 1: In this commit, the quantization/dequantization constants are kept unchanged, instead scaling factor 4 is rolled into fdct/idct. Fixed Q0 encoding tests on mobile: Before: 9560.567kbps Overall PSNR:50.255DB VPXSSIM:98.288 Now: 18035.774kbps Overall PSNR:73.022DB VPXSSIM:99.991 patch set 2: regenerated dc/ac quantizer lookup tables based on the scaling factor rolled in the fdct/idct. Also slightly extended the range towards the high quantizer end. patch set 3: slightly tweaked the quantizer tables and generated bits_per_mb table based on Paul's suggestions. patch set 4: fix a typo in idct, re-calculated tables relating active max Q to active min Q patch set 5: added rdmult lookup table based on Q patch set 6: fix rdmult scale: dct coefficient has scaled up by 4 patch set 7: make transform coefficients to be within 16bits patch set 8: normalize 2nd order quantizers patch set 9: fix mis-spellings patch set 10: change the configure script and macros to allow experimental code to be enabled at configure time with --enable-extend_qrange patch set 11: rebase for merge Change-Id: Ib50641ddd44aba2a52ed890222c309faa31cc59c
162 lines
5.3 KiB
C
162 lines
5.3 KiB
C
/*
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
|
|
#include "quant_common.h"
|
|
|
|
|
|
#if !CONFIG_EXTEND_QRANGE
|
|
static const int dc_qlookup[QINDEX_RANGE] =
|
|
{
|
|
4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 17,
|
|
18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 25, 25, 26, 27, 28,
|
|
29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43,
|
|
44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
|
|
59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
|
75, 76, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89,
|
|
91, 93, 95, 96, 98, 100, 101, 102, 104, 106, 108, 110, 112, 114, 116, 118,
|
|
122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 143, 145, 148, 151, 154, 157,
|
|
};
|
|
|
|
static const int ac_qlookup[QINDEX_RANGE] =
|
|
{
|
|
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
|
|
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
|
|
52, 53, 54, 55, 56, 57, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76,
|
|
78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108,
|
|
110, 112, 114, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152,
|
|
155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209,
|
|
213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284,
|
|
};
|
|
#else
|
|
|
|
static const int dc_qlookup[QINDEX_RANGE] =
|
|
{
|
|
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
|
20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 32, 34, 36, 38, 40, 42,
|
|
44, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88,
|
|
92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152,
|
|
156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 205, 210, 215, 220,
|
|
225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300,
|
|
310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460,
|
|
472, 484, 496, 508, 520, 532, 544, 556, 572, 588, 608, 628, 648, 668, 692, 720,
|
|
};
|
|
|
|
static const int ac_qlookup[QINDEX_RANGE] =
|
|
{
|
|
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
|
20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 51,
|
|
54, 57, 60, 63, 66, 69, 72, 76, 80, 84, 88, 92, 96, 100, 105, 110,
|
|
115, 120, 125, 130, 135, 140, 146, 152, 158, 164, 170, 176, 182, 188, 194, 200,
|
|
206, 212, 218, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320,
|
|
330, 340, 350, 360, 370, 380, 392, 404, 416, 428, 440, 454, 468, 482, 496, 510,
|
|
524, 540, 556, 572, 588, 604, 622, 640, 658, 676, 696, 716, 736, 756, 776, 796,
|
|
820, 844, 868, 892, 916, 944, 972, 1000, 1032, 1064, 1096, 1128, 1168, 1208, 1252, 1300
|
|
};
|
|
#endif
|
|
|
|
int vp8_dc_quant(int QIndex, int Delta)
|
|
{
|
|
int retval;
|
|
|
|
QIndex = QIndex + Delta;
|
|
|
|
if (QIndex > 127)
|
|
QIndex = 127;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
|
|
retval = dc_qlookup[ QIndex ];
|
|
return retval;
|
|
}
|
|
|
|
int vp8_dc2quant(int QIndex, int Delta)
|
|
{
|
|
int retval;
|
|
|
|
QIndex = QIndex + Delta;
|
|
|
|
if (QIndex > 127)
|
|
QIndex = 127;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
|
|
#if !CONFIG_EXTEND_QRANGE
|
|
retval = dc_qlookup[ QIndex ] * 2;
|
|
#else
|
|
retval = dc_qlookup[ QIndex ];
|
|
#endif
|
|
return retval;
|
|
|
|
}
|
|
int vp8_dc_uv_quant(int QIndex, int Delta)
|
|
{
|
|
int retval;
|
|
|
|
QIndex = QIndex + Delta;
|
|
|
|
if (QIndex > 117)
|
|
QIndex = 117;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
|
|
retval = dc_qlookup[ QIndex ];
|
|
|
|
return retval;
|
|
}
|
|
|
|
int vp8_ac_yquant(int QIndex)
|
|
{
|
|
int retval;
|
|
|
|
if (QIndex > 127)
|
|
QIndex = 127;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
|
|
retval = ac_qlookup[ QIndex ];
|
|
return retval;
|
|
}
|
|
|
|
int vp8_ac2quant(int QIndex, int Delta)
|
|
{
|
|
int retval;
|
|
|
|
QIndex = QIndex + Delta;
|
|
|
|
if (QIndex > 127)
|
|
QIndex = 127;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
#if !CONFIG_EXTEND_QRANGE
|
|
retval = (ac_qlookup[ QIndex ] * 155) / 100;
|
|
if (retval < 8)
|
|
retval = 8;
|
|
#else
|
|
retval = ac_qlookup[ QIndex ];
|
|
#endif
|
|
return retval;
|
|
}
|
|
int vp8_ac_uv_quant(int QIndex, int Delta)
|
|
{
|
|
int retval;
|
|
|
|
QIndex = QIndex + Delta;
|
|
|
|
if (QIndex > 127)
|
|
QIndex = 127;
|
|
else if (QIndex < 0)
|
|
QIndex = 0;
|
|
|
|
retval = ac_qlookup[ QIndex ];
|
|
return retval;
|
|
}
|