Moving q_trans[] table to vp9_quantize.{c, h}.
authorDmitry Kovalev <dkovalev@google.com>
Wed, 9 Apr 2014 20:35:39 +0000 (13:35 -0700)
committerDmitry Kovalev <dkovalev@google.com>
Wed, 9 Apr 2014 20:35:39 +0000 (13:35 -0700)
Change-Id: I1324c339815a47004ddccdaf651d24c60382b92f

vp9/encoder/vp9_onyx_if.c
vp9/encoder/vp9_onyx_int.h
vp9/encoder/vp9_quantize.c
vp9/encoder/vp9_quantize.h
vp9/vp9_cx_iface.c

index 3619ec8..081bf43 100644 (file)
@@ -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;
index e30fb02..18203f9 100644 (file)
@@ -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,
index c092ee4..31f3b3e 100644 (file)
@@ -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;
+}
index 7d231df..7a93883 100644 (file)
@@ -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
index 152e1f4..0623ad1 100644 (file)
@@ -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;