summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDmitry Kovalev <dkovalev@google.com>2014-04-09 13:35:39 -0700
committerDmitry Kovalev <dkovalev@google.com>2014-04-09 13:35:39 -0700
commitd1a396d8b92c85f3d8e60fd04c6c2b3d164ebb64 (patch)
treeac8c4d939ebd587ad50c6b4db2844bd1f103ad8c /vp9
parent7cc78c06e0edad1ece8b8ae186cd42b603e9eec9 (diff)
downloadlibvpx-d1a396d8b92c85f3d8e60fd04c6c2b3d164ebb64.tar
libvpx-d1a396d8b92c85f3d8e60fd04c6c2b3d164ebb64.tar.gz
libvpx-d1a396d8b92c85f3d8e60fd04c6c2b3d164ebb64.tar.bz2
libvpx-d1a396d8b92c85f3d8e60fd04c6c2b3d164ebb64.zip
Moving q_trans[] table to vp9_quantize.{c, h}.
Change-Id: I1324c339815a47004ddccdaf651d24c60382b92f
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_onyx_if.c23
-rw-r--r--vp9/encoder/vp9_onyx_int.h2
-rw-r--r--vp9/encoder/vp9_quantize.c27
-rw-r--r--vp9/encoder/vp9_quantize.h4
-rw-r--r--vp9/vp9_cx_iface.c12
5 files changed, 35 insertions, 33 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 3619ec89e..081bf430c 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -649,29 +649,6 @@ static void update_frame_size(VP9_COMP *cpi) {
init_macroblockd(cm, xd);
}
-// Table that converts 0-63 Q range values passed in outside to the Qindex
-// range used internally.
-const int q_trans[] = {
- 0, 4, 8, 12, 16, 20, 24, 28,
- 32, 36, 40, 44, 48, 52, 56, 60,
- 64, 68, 72, 76, 80, 84, 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, 204, 208, 212, 216, 220,
- 224, 228, 232, 236, 240, 244, 249, 255,
-};
-
-int vp9_reverse_trans(int x) {
- int i;
-
- for (i = 0; i < 64; i++)
- if (q_trans[i] >= x)
- return i;
-
- return 63;
-};
-
void vp9_new_framerate(VP9_COMP *cpi, double framerate) {
VP9_COMMON *const cm = &cpi->common;
RATE_CONTROL *const rc = &cpi->rc;
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index e30fb02b2..18203f96a 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -614,8 +614,6 @@ void vp9_scale_references(VP9_COMP *cpi);
void vp9_update_reference_frames(VP9_COMP *cpi);
-extern const int q_trans[];
-
int64_t vp9_rescale(int64_t val, int64_t num, int denom);
static INLINE void set_ref_ptrs(VP9_COMMON *cm, MACROBLOCKD *xd,
diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c
index c092ee41f..31f3b3e78 100644
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -284,3 +284,30 @@ void vp9_set_quantizer(VP9_COMMON *cm, int q) {
cm->uv_dc_delta_q = 0;
cm->uv_ac_delta_q = 0;
}
+
+// Table that converts 0-63 Q-range values passed in outside to the Qindex
+// range used internally.
+static const int quantizer_to_qindex[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 44, 48, 52, 56, 60,
+ 64, 68, 72, 76, 80, 84, 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, 204, 208, 212, 216, 220,
+ 224, 228, 232, 236, 240, 244, 249, 255,
+};
+
+int vp9_quantizer_to_qindex(int quantizer) {
+ return quantizer_to_qindex[quantizer];
+}
+
+int vp9_qindex_to_quantizer(int qindex) {
+ int quantizer;
+
+ for (quantizer = 0; quantizer < 64; ++quantizer)
+ if (quantizer_to_qindex[quantizer] >= qindex)
+ return quantizer;
+
+ return 63;
+}
diff --git a/vp9/encoder/vp9_quantize.h b/vp9/encoder/vp9_quantize.h
index 7d231dfd3..7a9388300 100644
--- a/vp9/encoder/vp9_quantize.h
+++ b/vp9/encoder/vp9_quantize.h
@@ -52,6 +52,10 @@ void vp9_init_quantizer(struct VP9_COMP *cpi);
void vp9_set_quantizer(struct VP9Common *cm, int q);
+int vp9_quantizer_to_qindex(int quantizer);
+
+int vp9_qindex_to_quantizer(int qindex);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index 152e1f46e..0623ad132 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -324,9 +324,9 @@ static vpx_codec_err_t set_encoder_config(
oxcf->target_bandwidth = cfg->rc_target_bitrate;
oxcf->rc_max_intra_bitrate_pct = extra_cfg->rc_max_intra_bitrate_pct;
- oxcf->best_allowed_q = q_trans[cfg->rc_min_quantizer];
- oxcf->worst_allowed_q = q_trans[cfg->rc_max_quantizer];
- oxcf->cq_level = q_trans[extra_cfg->cq_level];
+ oxcf->best_allowed_q = vp9_quantizer_to_qindex(cfg->rc_min_quantizer);
+ oxcf->worst_allowed_q = vp9_quantizer_to_qindex(cfg->rc_max_quantizer);
+ oxcf->cq_level = vp9_quantizer_to_qindex(extra_cfg->cq_level);
oxcf->fixed_q = -1;
oxcf->under_shoot_pct = cfg->rc_undershoot_pct;
@@ -449,10 +449,6 @@ static vpx_codec_err_t encoder_set_config(vpx_codec_alg_priv_t *ctx,
return res;
}
-
-int vp9_reverse_trans(int q);
-
-
static vpx_codec_err_t ctrl_get_param(vpx_codec_alg_priv_t *ctx, int ctrl_id,
va_list args) {
void *arg = va_arg(args, void *);
@@ -465,7 +461,7 @@ static vpx_codec_err_t ctrl_get_param(vpx_codec_alg_priv_t *ctx, int ctrl_id,
switch (ctrl_id) {
MAP(VP8E_GET_LAST_QUANTIZER, vp9_get_quantizer(ctx->cpi));
MAP(VP8E_GET_LAST_QUANTIZER_64,
- vp9_reverse_trans(vp9_get_quantizer(ctx->cpi)));
+ vp9_qindex_to_quantizer(vp9_get_quantizer(ctx->cpi)));
}
return VPX_CODEC_OK;