ref: 4a4ea28a3826d6a9843369bb8880cf49dc7c5dc0
parent: 0702d5ab27723162d0167006ef93010649c94895
author: Jerome Jiang <jianj@google.com>
date: Wed Jul 21 10:32:27 EDT 2021
Add control to get QP for all spatial layers Change-Id: I77a9884351e71649c8f8632293d9515c60f6adbc
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -3709,6 +3709,10 @@
cpi->rc.force_max_q = 0;
}
+ if (cpi->use_svc) {
+ cpi->svc.base_qindex[cpi->svc.spatial_layer_id] = *q;
+ }
+
if (!frame_is_intra_only(cm)) {
vp9_set_high_precision_mv(cpi, (*q) < HIGH_PRECISION_MV_QTHRESH);
}
--- a/vp9/encoder/vp9_svc_layercontext.h
+++ b/vp9/encoder/vp9_svc_layercontext.h
@@ -173,6 +173,8 @@
uint8_t fb_idx_temporal_layer_id[REF_FRAMES];
int spatial_layer_sync[VPX_SS_MAX_LAYERS];
+ // Quantizer for each spatial layer.
+ int base_qindex[VPX_SS_MAX_LAYERS];
uint8_t set_intra_only_frame;
uint8_t previous_frame_is_intra_only;
uint8_t superframe_has_layer_sync;
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -834,6 +834,17 @@
return VPX_CODEC_OK;
}
+static vpx_codec_err_t ctrl_get_quantizer_svc_layers(vpx_codec_alg_priv_t *ctx,
+ va_list args) {
+ int *const arg = va_arg(args, int *);
+ int i;
+ if (arg == NULL) return VPX_CODEC_INVALID_PARAM;
+ for (i = 0; i < VPX_SS_MAX_LAYERS; i++) {
+ arg[i] = ctx->cpi->svc.base_qindex[i];
+ }
+ return VPX_CODEC_OK;
+}
+
static vpx_codec_err_t ctrl_get_loopfilter_level(vpx_codec_alg_priv_t *ctx,
va_list args) {
int *const arg = va_arg(args, int *);
@@ -1988,6 +1999,7 @@
// Getters
{ VP8E_GET_LAST_QUANTIZER, ctrl_get_quantizer },
{ VP8E_GET_LAST_QUANTIZER_64, ctrl_get_quantizer64 },
+ { VP9E_GET_LAST_QUANTIZER_SVC_LAYERS, ctrl_get_quantizer_svc_layers },
{ VP9E_GET_LOOPFILTER_LEVEL, ctrl_get_loopfilter_level },
{ VP9_GET_REFERENCE, ctrl_get_reference },
{ VP9E_GET_SVC_LAYER_ID, ctrl_get_svc_layer_id },
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -732,6 +732,16 @@
* Supported in codecs: VP9
*/
VP9E_GET_LOOPFILTER_LEVEL,
+
+ /*!\brief Codec control to get last quantizers for all spatial layers.
+ *
+ * Return value uses an array of internal quantizers scale defined by the
+ * codec, for all spatial layers.
+ * The size of the array passed in should be #VPX_SS_MAX_LAYERS.
+ *
+ * Supported in codecs: VP9
+ */
+ VP9E_GET_LAST_QUANTIZER_SVC_LAYERS,
};
/*!\brief vpx 1-D scaling mode
@@ -989,6 +999,9 @@
#define VPX_CTRL_VP8E_GET_LAST_QUANTIZER
VPX_CTRL_USE_TYPE(VP8E_GET_LAST_QUANTIZER_64, int *)
#define VPX_CTRL_VP8E_GET_LAST_QUANTIZER_64
+VPX_CTRL_USE_TYPE(VP9E_GET_LAST_QUANTIZER_SVC_LAYERS, int *)
+#define VPX_CTRL_VP9E_GET_LAST_QUANTIZER_SVC_LAYERS
+
VPX_CTRL_USE_TYPE(VP9E_GET_SVC_LAYER_ID, vpx_svc_layer_id_t *)
#define VPX_CTRL_VP9E_GET_SVC_LAYER_ID