2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-11-09 02:09:30 +01:00
|
|
|
#include "vp9_rtcd.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/decoder/vp9_dequantize.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2012-11-28 19:41:40 +01:00
|
|
|
#include "vp9/decoder/vp9_onyxd_int.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
static void add_residual(const int16_t *diff, const uint8_t *pred, int pitch,
|
|
|
|
uint8_t *dest, int stride, int width, int height) {
|
2012-11-07 01:06:22 +01:00
|
|
|
int r, c;
|
|
|
|
|
|
|
|
for (r = 0; r < height; r++) {
|
|
|
|
for (c = 0; c < width; c++) {
|
|
|
|
int a = diff[c] + pred[c];
|
|
|
|
|
|
|
|
if (a < 0)
|
|
|
|
a = 0;
|
|
|
|
else if (a > 255)
|
|
|
|
a = 255;
|
|
|
|
|
|
|
|
dest[c] = (uint8_t) a;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest += stride;
|
|
|
|
diff += width;
|
|
|
|
pred += pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
static void add_constant_residual(const int16_t diff, const uint8_t *pred,
|
|
|
|
int pitch, uint8_t *dest, int stride,
|
|
|
|
int width, int height) {
|
|
|
|
int r, c;
|
|
|
|
|
|
|
|
for (r = 0; r < height; r++) {
|
|
|
|
for (c = 0; c < width; c++) {
|
|
|
|
int a = diff + pred[c];
|
|
|
|
|
|
|
|
if (a < 0)
|
|
|
|
a = 0;
|
|
|
|
else if (a > 255)
|
|
|
|
a = 255;
|
|
|
|
|
|
|
|
dest[c] = (uint8_t) a;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest += stride;
|
|
|
|
pred += pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 22:51:31 +01:00
|
|
|
void vp9_dequantize_b_c(BLOCKD *d) {
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t *DQ = d->dqcoeff;
|
2012-11-16 21:07:12 +01:00
|
|
|
const int16_t *Q = d->qcoeff;
|
|
|
|
const int16_t *DQC = d->dequant;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
DQ[i] = Q[i] * DQC[i];
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-06-25 21:26:09 +02:00
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_ht_dequant_idct_add_c(TX_TYPE tx_type, int16_t *input,
|
|
|
|
const int16_t *dq,
|
2012-11-10 02:50:13 +01:00
|
|
|
uint8_t *pred, uint8_t *dest,
|
2012-06-25 21:26:09 +02:00
|
|
|
int pitch, int stride) {
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[16];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-06-25 21:26:09 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
input[i] = dq[i] * input[i];
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_ihtllm_c(input, output, 4 << 1, tx_type, 4);
|
2012-06-25 21:26:09 +02:00
|
|
|
|
|
|
|
vpx_memset(input, 0, 32);
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
2012-06-25 21:26:09 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_ht_dequant_idct_add_8x8_c(TX_TYPE tx_type, int16_t *input,
|
|
|
|
const int16_t *dq,
|
2012-11-10 02:50:13 +01:00
|
|
|
uint8_t *pred, uint8_t *dest,
|
2012-08-02 18:07:33 +02:00
|
|
|
int pitch, int stride) {
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[64];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-08-02 18:07:33 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
input[0] = dq[0] * input[0];
|
|
|
|
for (i = 1; i < 64; i++) {
|
|
|
|
input[i] = dq[1] * input[i];
|
|
|
|
}
|
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_ihtllm_c(input, output, 16, tx_type, 8);
|
2012-08-02 18:07:33 +02:00
|
|
|
|
|
|
|
vpx_memset(input, 0, 128);
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 8, 8);
|
2012-08-02 18:07:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
|
2012-11-10 02:50:13 +01:00
|
|
|
uint8_t *dest, int pitch, int stride) {
|
|
|
|
int16_t output[16];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
input[i] = dq[i] * input[i];
|
|
|
|
}
|
2011-07-20 23:21:24 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
/* the idct halves ( >> 1) the pitch */
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_short_idct4x4llm_c(input, output, 4 << 1);
|
2010-05-28 20:28:12 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
vpx_memset(input, 0, 32);
|
2010-05-28 20:28:12 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_dc_idct_add_c(int16_t *input, const int16_t *dq, uint8_t *pred,
|
|
|
|
uint8_t *dest, int pitch, int stride, int Dc) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[16];
|
|
|
|
int16_t *diff_ptr = output;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
input[0] = (int16_t)Dc;
|
2011-07-20 23:21:24 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 1; i < 16; i++) {
|
|
|
|
input[i] = dq[i] * input[i];
|
|
|
|
}
|
2011-07-20 23:21:24 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
/* the idct halves ( >> 1) the pitch */
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_short_idct4x4llm_c(input, output, 4 << 1);
|
2010-05-28 20:28:12 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
vpx_memset(input, 0, 32);
|
2010-05-28 20:28:12 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
#if CONFIG_LOSSLESS
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_idct_add_lossless_c(int16_t *input, const int16_t *dq,
|
2012-11-10 02:50:13 +01:00
|
|
|
uint8_t *pred, uint8_t *dest,
|
2012-10-31 00:16:28 +01:00
|
|
|
int pitch, int stride) {
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[16];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
|
|
|
input[i] = dq[i] * input[i];
|
|
|
|
}
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
vpx_memset(input, 0, 32);
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_dc_idct_add_lossless_c(int16_t *input, const int16_t *dq,
|
2012-11-10 02:50:13 +01:00
|
|
|
uint8_t *pred,
|
|
|
|
uint8_t *dest,
|
2012-10-31 00:16:28 +01:00
|
|
|
int pitch, int stride, int dc) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[16];
|
|
|
|
int16_t *diff_ptr = output;
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
input[0] = (int16_t)dc;
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 1; i < 16; i++) {
|
|
|
|
input[i] = dq[i] * input[i];
|
|
|
|
}
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_short_inv_walsh4x4_x8_c(input, output, 4 << 1);
|
2012-07-14 00:21:29 +02:00
|
|
|
vpx_memset(input, 0, 32);
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 4, 4);
|
Add lossless compression mode.
This commit adds lossless compression capability to the experimental
branch. The lossless experiment can be enabled using --enable-lossless
in configure. When the experiment is enabled, the encoder will use
lossless compression mode by command line option --lossless, and the
decoder automatically recognizes a losslessly encoded clip and decodes
accordingly.
To achieve the lossless coding, this commit has changed the following:
1. To encode at lossless mode, encoder forces the use of unit
quantizer, i.e, Q 0, where effective quantization is 1. Encoder also
disables the usage of 8x8 transform and allows only 4x4 transform;
2. At Q 0, the first order 4x4 DCT/IDCT have been switched over
to a pair of forward and inverse Walsh-Hadamard Transform
(http://goo.gl/EIsfy), with proper scaling applied to match the range
of the original 4x4 DCT/IDCT pair;
3. At Q 0, the second order remains to use the previous
walsh-hadamard transform pair. However, to maintain the reversibility
in second order transform at Q 0, scaling down is applied to first
order DC coefficients prior to forward transform, and scaling up is
applied to the second order output prior to quantization. Symmetric
upscaling and downscaling are added around inverse second order
transform;
4. At lossless mode, encoder also disables a number of minor
features to ensure no loss is introduced, these features includes:
a. Trellis quantization optimization
b. Loop filtering
c. Aggressive zero-binning, rounding and zero-bin boosting
d. Mode based zero-bin boosting
Lossless coding test was performed on all clips within the derf set,
to verify that the commit has achieved lossless compression for all
clips. The average compression ratio is around 2.57 to 1.
(http://goo.gl/dEShs)
Change-Id: Ia3aba7dd09df40dd590f93b9aba134defbc64e34
2012-06-14 04:03:31 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-10-30 22:51:31 +01:00
|
|
|
void vp9_dequantize_b_2x2_c(BLOCKD *d) {
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t *DQ = d->dqcoeff;
|
2012-11-16 21:07:12 +01:00
|
|
|
const int16_t *Q = d->qcoeff;
|
|
|
|
const int16_t *DQC = d->dequant;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-07-14 00:21:29 +02:00
|
|
|
for (i = 0; i < 16; i++) {
|
2012-11-10 02:50:13 +01:00
|
|
|
DQ[i] = (int16_t)((Q[i] * DQC[i]));
|
2012-07-14 00:21:29 +02:00
|
|
|
}
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_idct_add_8x8_c(int16_t *input, const int16_t *dq,
|
|
|
|
uint8_t *pred, uint8_t *dest, int pitch,
|
|
|
|
int stride, int dc, uint16_t eobs) {
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[64];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-07-14 00:21:29 +02:00
|
|
|
int i;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
/* If dc is 1, then input[0] is the reconstructed value, do not need
|
|
|
|
* dequantization. Also, when dc is 1, dc is counted in eobs, namely eobs >=1.
|
|
|
|
*/
|
|
|
|
if (!dc)
|
|
|
|
input[0] *= dq[0];
|
2011-11-10 21:54:22 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
/* The calculation can be simplified if there are not many non-zero dct
|
|
|
|
* coefficients. Use eobs to decide what to do.
|
|
|
|
* TODO(yunqingwang): "eobs = 1" case is also handled in vp9_short_idct8x8_c.
|
|
|
|
* Combine that with code here.
|
|
|
|
*/
|
|
|
|
if (eobs == 0) {
|
|
|
|
/* All 0 DCT coefficient */
|
|
|
|
vp9_copy_mem8x8(pred, pitch, dest, stride);
|
|
|
|
} else if (eobs == 1) {
|
|
|
|
/* DC only DCT coefficient. */
|
|
|
|
int16_t out;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
/* Note: the idct1 will need to be modified accordingly whenever
|
|
|
|
* vp9_short_idct8x8_c() is modified. */
|
|
|
|
out = (input[0] + 1 + (input[0] < 0)) >> 2;
|
|
|
|
out = out << 3;
|
|
|
|
out = (out + 32) >> 7;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
input[0] = 0;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_constant_residual(out, pred, pitch, dest, stride, 8, 8);
|
|
|
|
} else if (eobs <= 10) {
|
|
|
|
input[1] = input[1] * dq[1];
|
|
|
|
input[2] = input[2] * dq[1];
|
|
|
|
input[3] = input[3] * dq[1];
|
|
|
|
input[8] = input[8] * dq[1];
|
|
|
|
input[9] = input[9] * dq[1];
|
|
|
|
input[10] = input[10] * dq[1];
|
|
|
|
input[16] = input[16] * dq[1];
|
|
|
|
input[17] = input[17] * dq[1];
|
|
|
|
input[24] = input[24] * dq[1];
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
vp9_short_idct10_8x8_c(input, output, 16);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
input[0] = input[1] = input[2] = input[3] = 0;
|
|
|
|
input[8] = input[9] = input[10] = 0;
|
|
|
|
input[16] = input[17] = 0;
|
|
|
|
input[24] = 0;
|
2012-07-14 00:21:29 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 8, 8);
|
|
|
|
} else {
|
|
|
|
// recover quantizer for 4 4x4 blocks
|
|
|
|
for (i = 1; i < 64; i++) {
|
|
|
|
input[i] = input[i] * dq[1];
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
2012-11-10 02:50:13 +01:00
|
|
|
// the idct halves ( >> 1) the pitch
|
|
|
|
vp9_short_idct8x8_c(input, output, 16);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
vpx_memset(input, 0, 128);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 8, 8);
|
2011-02-14 23:18:18 +01:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
}
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
void vp9_ht_dequant_idct_add_16x16_c(TX_TYPE tx_type, int16_t *input,
|
2012-11-16 21:07:12 +01:00
|
|
|
const int16_t *dq, uint8_t *pred,
|
|
|
|
uint8_t *dest, int pitch, int stride) {
|
2012-11-10 02:50:13 +01:00
|
|
|
int16_t output[256];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-11-07 01:06:22 +01:00
|
|
|
int i;
|
2012-08-29 20:25:38 +02:00
|
|
|
|
|
|
|
input[0]= input[0] * dq[0];
|
|
|
|
|
|
|
|
// recover quantizer for 4 4x4 blocks
|
|
|
|
for (i = 1; i < 256; i++)
|
|
|
|
input[i] = input[i] * dq[1];
|
|
|
|
|
|
|
|
// inverse hybrid transform
|
2012-10-31 00:25:53 +01:00
|
|
|
vp9_ihtllm_c(input, output, 32, tx_type, 16);
|
2012-08-29 20:25:38 +02:00
|
|
|
|
|
|
|
// the idct halves ( >> 1) the pitch
|
2012-10-31 00:25:53 +01:00
|
|
|
// vp9_short_idct16x16_c(input, output, 32);
|
2012-08-29 20:25:38 +02:00
|
|
|
|
|
|
|
vpx_memset(input, 0, 512);
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
|
2012-08-29 20:25:38 +02:00
|
|
|
}
|
|
|
|
|
2012-11-16 21:07:12 +01:00
|
|
|
void vp9_dequant_idct_add_16x16_c(int16_t *input, const int16_t *dq,
|
|
|
|
uint8_t *pred, uint8_t *dest, int pitch,
|
|
|
|
int stride, uint16_t eobs) {
|
2012-11-07 01:06:22 +01:00
|
|
|
int16_t output[256];
|
|
|
|
int16_t *diff_ptr = output;
|
2012-11-10 02:50:13 +01:00
|
|
|
int i;
|
2012-08-03 02:03:14 +02:00
|
|
|
|
2012-11-07 01:06:22 +01:00
|
|
|
/* The calculation can be simplified if there are not many non-zero dct
|
|
|
|
* coefficients. Use eobs to separate different cases. */
|
|
|
|
if (eobs == 0) {
|
|
|
|
/* All 0 DCT coefficient */
|
|
|
|
vp9_copy_mem16x16(pred, pitch, dest, stride);
|
|
|
|
} else if (eobs == 1) {
|
|
|
|
/* DC only DCT coefficient. */
|
|
|
|
int16_t out;
|
2012-08-03 02:03:14 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
/* Note: the idct1 will need to be modified accordingly whenever
|
|
|
|
* vp9_short_idct16x16_c() is modified. */
|
2012-11-07 01:06:22 +01:00
|
|
|
out = (input[0] * dq[0] + 2) >> 2;
|
|
|
|
out = (out + 2) >> 2;
|
|
|
|
out = (out + 4) >> 3;
|
2012-08-03 02:03:14 +02:00
|
|
|
|
2012-11-07 01:06:22 +01:00
|
|
|
input[0] = 0;
|
2012-08-03 02:03:14 +02:00
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_constant_residual(out, pred, pitch, dest, stride, 16, 16);
|
2012-11-07 01:06:22 +01:00
|
|
|
} else if (eobs <= 10) {
|
|
|
|
input[0]= input[0] * dq[0];
|
|
|
|
input[1] = input[1] * dq[1];
|
|
|
|
input[2] = input[2] * dq[1];
|
|
|
|
input[3] = input[3] * dq[1];
|
|
|
|
input[16] = input[16] * dq[1];
|
|
|
|
input[17] = input[17] * dq[1];
|
|
|
|
input[18] = input[18] * dq[1];
|
|
|
|
input[32] = input[32] * dq[1];
|
|
|
|
input[33] = input[33] * dq[1];
|
|
|
|
input[48] = input[48] * dq[1];
|
|
|
|
|
|
|
|
// the idct halves ( >> 1) the pitch
|
|
|
|
vp9_short_idct10_16x16_c(input, output, 32);
|
|
|
|
|
|
|
|
input[0] = input[1] = input[2] = input[3] = 0;
|
|
|
|
input[16] = input[17] = input[18] = 0;
|
|
|
|
input[32] = input[33] = 0;
|
|
|
|
input[48] = 0;
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
|
2012-11-07 01:06:22 +01:00
|
|
|
} else {
|
|
|
|
input[0]= input[0] * dq[0];
|
|
|
|
|
|
|
|
// recover quantizer for 4 4x4 blocks
|
|
|
|
for (i = 1; i < 256; i++)
|
|
|
|
input[i] = input[i] * dq[1];
|
|
|
|
|
|
|
|
// the idct halves ( >> 1) the pitch
|
|
|
|
vp9_short_idct16x16_c(input, output, 32);
|
|
|
|
|
|
|
|
vpx_memset(input, 0, 512);
|
|
|
|
|
2012-11-10 02:50:13 +01:00
|
|
|
add_residual(diff_ptr, pred, pitch, dest, stride, 16, 16);
|
2012-08-03 02:03:14 +02:00
|
|
|
}
|
|
|
|
}
|