summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_onyx.h2
-rw-r--r--vp9/encoder/vp9_onyx_if.c28
-rw-r--r--vp9/vp9_cx_iface.c80
3 files changed, 86 insertions, 24 deletions
diff --git a/vp9/common/vp9_onyx.h b/vp9/common/vp9_onyx.h
index 452dd6b89..acb4724e5 100644
--- a/vp9/common/vp9_onyx.h
+++ b/vp9/common/vp9_onyx.h
@@ -221,6 +221,8 @@ extern "C"
int vp9_set_size_literal(VP9_PTR comp, unsigned int width,
unsigned int height);
+ int vp9_switch_layer(VP9_PTR comp, int layer);
+
void vp9_set_svc(VP9_PTR comp, int use_svc);
int vp9_get_quantizer(VP9_PTR c);
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index b52a101a5..f6b2a2876 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -4226,9 +4226,37 @@ int vp9_set_size_literal(VP9_PTR comp, unsigned int width,
return 0;
}
+int vp9_switch_layer(VP9_PTR comp, int layer) {
+ VP9_COMP *cpi = (VP9_COMP *)comp;
+
+ if (cpi->use_svc) {
+ cpi->current_layer = layer;
+
+ // Use buffer i for layer i LST
+ cpi->lst_fb_idx = layer;
+
+ // Use buffer i-1 for layer i Alt (Inter-layer prediction)
+ if (layer != 0) cpi->alt_fb_idx = layer - 1;
+
+ // Use the rest for Golden
+ if (layer < 2 * cpi->number_spatial_layers - NUM_REF_FRAMES)
+ cpi->gld_fb_idx = cpi->lst_fb_idx;
+ else
+ cpi->gld_fb_idx = 2 * cpi->number_spatial_layers - 1 - layer;
+
+ printf("Switching to layer %d:\n", layer);
+ printf("Using references: LST/GLD/ALT [%d|%d|%d]\n", cpi->lst_fb_idx,
+ cpi->gld_fb_idx, cpi->alt_fb_idx);
+ } else {
+ printf("Switching layer not supported. Enable SVC first \n");
+ }
+ return 0;
+}
+
void vp9_set_svc(VP9_PTR comp, int use_svc) {
VP9_COMP *cpi = (VP9_COMP *)comp;
cpi->use_svc = use_svc;
+ if (cpi->use_svc) printf("Enabled SVC encoder \n");
return;
}
diff --git a/vp9/vp9_cx_iface.c b/vp9/vp9_cx_iface.c
index b744ec6e6..fb380e1db 100644
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -442,6 +442,8 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx,
MAP(VP8E_SET_ARNR_TYPE, xcfg.arnr_type);
MAP(VP8E_SET_TUNING, xcfg.tuning);
MAP(VP8E_SET_CQ_LEVEL, xcfg.cq_level);
+ MAP(VP9E_SET_MAX_Q, ctx->cfg.rc_max_quantizer);
+ MAP(VP9E_SET_MIN_Q, ctx->cfg.rc_min_quantizer);
MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct);
MAP(VP9E_SET_LOSSLESS, xcfg.lossless);
MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode);
@@ -1027,40 +1029,66 @@ static vpx_codec_err_t vp9e_set_scalemode(vpx_codec_alg_priv_t *ctx,
}
}
-static vpx_codec_err_t vp9e_set_svc(vpx_codec_alg_priv_t *ctx, int ctr_id,
- va_list args) {
- int data = va_arg(args, int);
- vp9_set_svc(ctx->cpi, data);
- return VPX_CODEC_OK;
+static vpx_codec_err_t vp9e_set_width(vpx_codec_alg_priv_t *ctx, int ctr_id,
+ va_list args) {
+ unsigned int *data = va_arg(args, unsigned int *);
+ if (data) {
+ int res;
+ res = vp9_set_size_literal(ctx->cpi, *data, 0);
+ if (!res) {
+ return VPX_CODEC_OK;
+ } else {
+ return VPX_CODEC_INVALID_PARAM;
+ }
+ } else {
+ return VPX_CODEC_INVALID_PARAM;
+ }
}
-static vpx_codec_err_t vp9e_set_svc_parameters(vpx_codec_alg_priv_t *ctx,
- int ctr_id, va_list args) {
- vpx_svc_parameters_t *data = va_arg(args, vpx_svc_parameters_t *);
- VP9_COMP *cpi = (VP9_COMP *)ctx->cpi;
- vpx_svc_parameters_t params;
+static vpx_codec_err_t vp9e_set_height(vpx_codec_alg_priv_t *ctx,
+ int ctr_id,
+ va_list args) {
+ unsigned int *data = va_arg(args, unsigned int *);
+
+ if (data) {
+ int res;
+ res = vp9_set_size_literal(ctx->cpi, 0, *data);
- if (!data) {
+ if (!res) {
+ return VPX_CODEC_OK;
+ } else {
+ return VPX_CODEC_INVALID_PARAM;
+ }
+ } else {
return VPX_CODEC_INVALID_PARAM;
}
+}
+
+static vpx_codec_err_t vp9e_set_layer(vpx_codec_alg_priv_t *ctx,
+ int ctr_id,
+ va_list args) {
+ unsigned int *data = va_arg(args, unsigned int *);
- params = *(vpx_svc_parameters_t *)data;
+ if (data) {
+ int res;
+ res = 0;
- cpi->current_layer = params.layer;
- cpi->lst_fb_idx = params.lst_fb_idx;
- cpi->gld_fb_idx = params.gld_fb_idx;
- cpi->alt_fb_idx = params.alt_fb_idx;
+ res = vp9_switch_layer(ctx->cpi, *data);
- if (vp9_set_size_literal(ctx->cpi, params.width, params.height) != 0) {
+ if (!res) {
+ return VPX_CODEC_OK;
+ } else {
+ return VPX_CODEC_INVALID_PARAM;
+ }
+ } else {
return VPX_CODEC_INVALID_PARAM;
}
+}
- ctx->cfg.rc_max_quantizer = params.max_quantizer;
- ctx->cfg.rc_min_quantizer = params.min_quantizer;
-
- set_vp9e_config(&ctx->oxcf, ctx->cfg, ctx->vp8_cfg);
- vp9_change_config(ctx->cpi, &ctx->oxcf);
-
+static vpx_codec_err_t vp9e_set_svc(vpx_codec_alg_priv_t *ctx, int ctr_id,
+ va_list args) {
+ int data = va_arg(args, int);
+ vp9_set_svc(ctx->cpi, data);
return VPX_CODEC_OK;
}
@@ -1088,12 +1116,16 @@ static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = {
{VP8E_SET_ARNR_TYPE, set_param},
{VP8E_SET_TUNING, set_param},
{VP8E_SET_CQ_LEVEL, set_param},
+ {VP9E_SET_MAX_Q, set_param},
+ {VP9E_SET_MIN_Q, set_param},
{VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param},
{VP9E_SET_LOSSLESS, set_param},
{VP9E_SET_FRAME_PARALLEL_DECODING, set_param},
{VP9_GET_REFERENCE, get_reference},
+ {VP9E_SET_WIDTH, vp9e_set_width},
+ {VP9E_SET_HEIGHT, vp9e_set_height},
+ {VP9E_SET_LAYER, vp9e_set_layer},
{VP9E_SET_SVC, vp9e_set_svc},
- {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters},
{ -1, NULL},
};