summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2013-04-30 13:39:50 -0700
committerDmitry Kovalev <dkovalev@google.com>2013-04-30 13:39:50 -0700
commit3f6c6ffc86911d213f8df301eff3be2d0977a81c (patch)
tree2e4a9fd776c20701a28f43d11fed8202c8befb46 /vp9
parent347ad7fff0459dc8b9dfc9613e66d594c44b57b0 (diff)
downloadlibvpx-3f6c6ffc86911d213f8df301eff3be2d0977a81c.tar
libvpx-3f6c6ffc86911d213f8df301eff3be2d0977a81c.tar.gz
libvpx-3f6c6ffc86911d213f8df301eff3be2d0977a81c.tar.bz2
libvpx-3f6c6ffc86911d213f8df301eff3be2d0977a81c.zip
Adding vp9_get_qindex function.
Moving common code from encoder and decoder to vp9_get_qindex function. Also moving quant-related constants from vp9_onyxc_int.h to vp9_quant_common.h. Change-Id: I70c5bfbaa1c8bf00fde0bfc459d077f88b6d46c8
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_onyxc_int.h8
-rw-r--r--vp9/common/vp9_quant_common.c14
-rw-r--r--vp9/common/vp9_quant_common.h8
-rw-r--r--vp9/decoder/vp9_decodframe.c14
-rw-r--r--vp9/encoder/vp9_quantize.c19
5 files changed, 24 insertions, 39 deletions
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index cbead80f8..211783e51 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -18,6 +18,7 @@
#include "vp9/common/vp9_entropymv.h"
#include "vp9/common/vp9_entropy.h"
#include "vp9/common/vp9_entropymode.h"
+#include "vp9/common/vp9_quant_common.h"
#if CONFIG_POSTPROC
#include "vp9/common/vp9_postproc.h"
@@ -31,13 +32,6 @@
void vp9_initialize_common(void);
-#define MINQ 0
-
-#define MAXQ 255
-#define QINDEX_BITS 8
-
-#define QINDEX_RANGE (MAXQ + 1)
-
#if CONFIG_MULTIPLE_ARF
#define NUM_REF_FRAMES 8
#define NUM_REF_FRAMES_LG2 3
diff --git a/vp9/common/vp9_quant_common.c b/vp9/common/vp9_quant_common.c
index 2e9e4cab2..5907b4f58 100644
--- a/vp9/common/vp9_quant_common.c
+++ b/vp9/common/vp9_quant_common.c
@@ -10,6 +10,7 @@
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_quant_common.h"
+#include "vp9/common/vp9_seg_common.h"
static int16_t dc_qlookup[QINDEX_RANGE];
static int16_t ac_qlookup[QINDEX_RANGE];
@@ -44,3 +45,16 @@ int16_t vp9_dc_quant(int qindex, int delta) {
int16_t vp9_ac_quant(int qindex, int delta) {
return ac_qlookup[clamp(qindex + delta, 0, MAXQ)];
}
+
+
+int vp9_get_qindex(MACROBLOCKD *xd, int segment_id, int base_qindex) {
+ if (vp9_segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
+ const int data = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
+ return xd->mb_segment_abs_delta == SEGMENT_ABSDATA ?
+ data : // Abs value
+ clamp(base_qindex + data, 0, MAXQ); // Delta value
+ } else {
+ return base_qindex;
+ }
+}
+
diff --git a/vp9/common/vp9_quant_common.h b/vp9/common/vp9_quant_common.h
index 7daf15dc1..ded94269a 100644
--- a/vp9/common/vp9_quant_common.h
+++ b/vp9/common/vp9_quant_common.h
@@ -12,11 +12,17 @@
#define VP9_COMMON_VP9_QUANT_COMMON_H_
#include "vp9/common/vp9_blockd.h"
-#include "vp9/common/vp9_onyxc_int.h"
+
+#define MINQ 0
+#define MAXQ 255
+#define QINDEX_RANGE (MAXQ - MINQ + 1)
+#define QINDEX_BITS 8
void vp9_init_quant_tables();
int16_t vp9_dc_quant(int qindex, int delta);
int16_t vp9_ac_quant(int qindex, int delta);
+int vp9_get_qindex(MACROBLOCKD *mb, int segment_id, int base_qindex);
+
#endif // VP9_COMMON_VP9_QUANT_COMMON_H_
diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c
index 64a939bd1..01e9a2b89 100644
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -181,22 +181,10 @@ void vp9_init_dequantizer(VP9_COMMON *pc) {
}
}
-static int get_qindex(MACROBLOCKD *mb, int segment_id, int base_qindex) {
- // Set the Q baseline allowing for any segment level adjustment
- if (vp9_segfeature_active(mb, segment_id, SEG_LVL_ALT_Q)) {
- const int data = vp9_get_segdata(mb, segment_id, SEG_LVL_ALT_Q);
- return mb->mb_segment_abs_delta == SEGMENT_ABSDATA ?
- data : // Abs value
- clamp(base_qindex + data, 0, MAXQ); // Delta value
- } else {
- return base_qindex;
- }
-}
-
static void mb_init_dequantizer(VP9_COMMON *pc, MACROBLOCKD *xd) {
int i;
const int segment_id = xd->mode_info_context->mbmi.segment_id;
- xd->q_index = get_qindex(xd, segment_id, pc->base_qindex);
+ xd->q_index = vp9_get_qindex(xd, segment_id, pc->base_qindex);
xd->plane[0].dequant = pc->y_dequant[xd->q_index];
for (i = 1; i < MAX_MB_PLANE; i++)
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index 77e19721c..6c8474c0e 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -318,27 +318,10 @@ void vp9_init_quantizer(VP9_COMP *cpi) {
void vp9_mb_init_quantizer(VP9_COMP *cpi, MACROBLOCK *x) {
int i;
- int qindex;
MACROBLOCKD *xd = &x->e_mbd;
int zbin_extra;
int segment_id = xd->mode_info_context->mbmi.segment_id;
-
- // Select the baseline MB Q index allowing for any segment level change.
- if (vp9_segfeature_active(xd, segment_id, SEG_LVL_ALT_Q)) {
- if (xd->mb_segment_abs_delta == SEGMENT_ABSDATA) {
- // Abs Value
- qindex = vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
- } else {
- // Delta Value
- qindex = cpi->common.base_qindex +
- vp9_get_segdata(xd, segment_id, SEG_LVL_ALT_Q);
-
- // Clamp to valid range
- qindex = clamp(qindex, 0, MAXQ);
- }
- } else {
- qindex = cpi->common.base_qindex;
- }
+ const int qindex = vp9_get_qindex(xd, segment_id, cpi->common.base_qindex);
// Y
zbin_extra = (cpi->common.y_dequant[qindex][1] *