Disable svc for lag_in_frames > 0 in good_quality mode
SVC for nonzero lag_in_frames in good_quality mode is
not currently supported/tested.
This previous patch allows for it, but it was not merged in:
https://aomedia-review.googlesource.com/c/aom/+/193401
So for now disable the usage under these conditions.
Added unittest that reproduces the issue.
Bug: b:449376308
Change-Id: Ieacf306bf6e4d51bf3330fe0ead56dc85a7e1a75
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 295ff0d..89d9b92 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -4011,6 +4011,8 @@
if (ppi->number_spatial_layers > 1 || ppi->number_temporal_layers > 1) {
unsigned int sl, tl;
+ // Disable svc for lag_in_frames > 0.
+ if (cpi->oxcf.gf_cfg.lag_in_frames > 0) return AOM_CODEC_INVALID_PARAM;
ctx->ppi->use_svc = 1;
const int num_layers =
ppi->number_spatial_layers * ppi->number_temporal_layers;
diff --git a/test/encode_api_test.cc b/test/encode_api_test.cc
index 858bf46..3bf2205 100644
--- a/test/encode_api_test.cc
+++ b/test/encode_api_test.cc
@@ -1645,4 +1645,44 @@
ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
}
+// This test is based on the issue:449376308. The segfault in
+// av1_update_layer_context_change_config() is triggered
+// by doing svc with nonzero lag_in_frames and good_quality usage.
+// Note good_quality mode is needed because for realtime mode lag_in_frames
+// is forced to 0 in set_encoder_config() .
+TEST(EncodeAPI, Issue449376308) {
+ aom_codec_iface_t *iface = aom_codec_av1_cx();
+ aom_codec_enc_cfg_t cfg;
+ ASSERT_EQ(aom_codec_enc_config_default(iface, &cfg, AOM_USAGE_GOOD_QUALITY),
+ AOM_CODEC_OK);
+ cfg.g_w = 320;
+ cfg.g_h = 240;
+ cfg.g_timebase.num = 1;
+ cfg.g_timebase.den = 30;
+ cfg.rc_target_bitrate = 1000;
+ cfg.g_lag_in_frames = 25;
+ aom_codec_ctx_t enc;
+ ASSERT_EQ(aom_codec_enc_init(&enc, iface, &cfg, 0), AOM_CODEC_OK);
+ // AV1E_SET_SVC_PARAMS
+ aom_svc_params_t svc_params = {};
+ svc_params.number_spatial_layers = 3;
+ svc_params.number_temporal_layers = 2;
+ for (int i = 0; i < AOM_MAX_LAYERS; i++) {
+ svc_params.max_quantizers[i] = 30;
+ svc_params.min_quantizers[i] = 0;
+ svc_params.layer_target_bitrate[i] = 1000;
+ }
+ for (int i = 0; i < AOM_MAX_SS_LAYERS; i++) {
+ svc_params.scaling_factor_num[i] = 1;
+ svc_params.scaling_factor_den[i] = 1;
+ }
+ for (int i = 0; i < AOM_MAX_TS_LAYERS; i++) {
+ svc_params.framerate_factor[i] = 1;
+ }
+ // set_svc_params should fail since lag_in_frames > 0.
+ EXPECT_NE(aom_codec_control(&enc, AV1E_SET_SVC_PARAMS, &svc_params),
+ AOM_CODEC_OK);
+ ASSERT_EQ(aom_codec_destroy(&enc), AOM_CODEC_OK);
+}
+
} // namespace