rtc: Fix to lm=3 pattern in svc sample encoder
For the 3TL pattern with multiple references (lm=3):
fix the ALTREF ref_idx so that the ALTREF trails
the enhancement layer frames (in current code it
was only trailing on the TL0 frames), so TL2/TL1
frames can also use the ALTREF as a reference.
Also enable compound prediction for (LAST, ALTREF)
for speed >= 7 for pattern lm = 3.
For speed 7 on rtc _set for 3TL with lm = 3:
bdrate gain from altref ref_idx fix is ~1-2%,
bdrate gain from enabling compound prediction is ~5%.
Change-Id: Ia5def436e7c7c6a27cb74dfe33d231f862022cf0
diff --git a/examples/svc_encoder_rtc.c b/examples/svc_encoder_rtc.c
index 9aa4d83..745468a 100644
--- a/examples/svc_encoder_rtc.c
+++ b/examples/svc_encoder_rtc.c
@@ -560,7 +560,7 @@
aom_svc_layer_id_t *layer_id,
aom_svc_ref_frame_config_t *ref_frame_config,
int *use_svc_control, int spatial_layer_id,
- int is_key_frame, int ksvc_mode) {
+ int is_key_frame, int ksvc_mode, int speed) {
int i;
int enable_longterm_temporal_ref = 1;
int shift = (layering_mode == 8) ? 2 : 0;
@@ -646,8 +646,12 @@
// Keep golden fixed at slot 3.
ref_frame_config->ref_idx[SVC_GOLDEN_FRAME] = 3;
- // Cyclically refresh slots 4, 5, 6, 7, for lag altref.
- lag_index = 4 + (base_count % 4);
+ // Cyclically refresh slots 5, 6, 7, for lag altref.
+ lag_index = 5;
+ if (base_count > 0) {
+ lag_index = 5 + (base_count % 3);
+ if (superframe_cnt % 4 != 0) lag_index = 5 + ((base_count + 1) % 3);
+ }
// Set the altref slot to lag_index.
ref_frame_config->ref_idx[SVC_ALTREF_FRAME] = lag_index;
if (superframe_cnt % 4 == 0) {
@@ -681,6 +685,8 @@
// Every frame can reference GOLDEN AND ALTREF.
ref_frame_config->reference[SVC_GOLDEN_FRAME] = 1;
ref_frame_config->reference[SVC_ALTREF_FRAME] = 1;
+ // Allow for compound prediction using LAST and ALTREF.
+ if (speed >= 7) ref_frame_config->ref_frame_comp[2] = 1;
break;
case 4:
// 3-temporal layer: but middle layer updates GF, so 2nd TL2 will
@@ -1305,7 +1311,8 @@
// buffer index.
set_layer_pattern(app_input.layering_mode, frame_cnt, &layer_id,
&ref_frame_config, &use_svc_control, slx,
- is_key_frame, (app_input.layering_mode == 10));
+ is_key_frame, (app_input.layering_mode == 10),
+ app_input.speed);
aom_codec_control(&codec, AV1E_SET_SVC_LAYER_ID, &layer_id);
if (use_svc_control)
aom_codec_control(&codec, AV1E_SET_SVC_REF_FRAME_CONFIG,