From efa786d4649cb39919170d745d4206309b463575 Mon Sep 17 00:00:00 2001 From: Marco Paniconi Date: Wed, 31 Jan 2018 16:56:04 +0000 Subject: [PATCH] vp9 svc: Make top layer non-ref: for 2 TL case Only affects 2 temporal layer case. Modified the flags for 2 temporal layers to make top layer (top spatial, top temporal) a non-reference frame, conistent with the 3 TL case. Add mismatch check to the datarate test of changing svc pattern on the fly, which is test for 2 temporal layers. This re-applies the change: 254e2f5501d, that was reverted in: 658eb1d675. Change-Id: Ib5fd4a7a0312c0c05329ae75baac480af34b4694 --- examples/vp9_spatial_svc_encoder.c | 4 ++++ test/datarate_test.cc | 7 +++++++ vp9/encoder/vp9_svc_layercontext.c | 2 ++ 3 files changed, 13 insertions(+) diff --git a/examples/vp9_spatial_svc_encoder.c b/examples/vp9_spatial_svc_encoder.c index 85014a0cc..d49a2307d 100644 --- a/examples/vp9_spatial_svc_encoder.c +++ b/examples/vp9_spatial_svc_encoder.c @@ -589,6 +589,10 @@ void set_frame_flags_bypass_mode(int sl, int tl, int num_spatial_layers, } else { ref_frame_config->frame_flags[sl] = VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF; + if (sl == num_spatial_layers - 1) + ref_frame_config->frame_flags[sl] = + VP8_EFLAG_NO_UPD_ARF | VP8_EFLAG_NO_REF_ARF | + VP8_EFLAG_NO_UPD_LAST | VP8_EFLAG_NO_UPD_GF; } } if (tl == 0) { diff --git a/test/datarate_test.cc b/test/datarate_test.cc index 8e68174ee..158adf425 100644 --- a/test/datarate_test.cc +++ b/test/datarate_test.cc @@ -1879,6 +1879,13 @@ TEST_P(DatarateOnePassCbrSvc, OnePassCbrSvc3SL2TLDynamicPatternChange) { ASSERT_NO_FATAL_FAILURE(RunLoop(&video)); CheckLayerRateTargeting(&cfg_, number_spatial_layers_, number_temporal_layers_, file_datarate_, 0.78, 1.15); +#if CONFIG_VP9_DECODER + // Number of temporal layers > 1, so half of the frames in this SVC pattern + // will be non-reference frame and hence encoder will avoid loopfilter. + // Since frame dropper is off, we can expect 200 (half of the sequence) + // mismatched frames. + EXPECT_EQ(static_cast(200), GetMismatchFrames()); +#endif } // Check basic rate targeting for 1 pass CBR SVC with 3 spatial layers and on diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c index 35d5ec3e0..54789ee70 100644 --- a/vp9/encoder/vp9_svc_layercontext.c +++ b/vp9/encoder/vp9_svc_layercontext.c @@ -549,6 +549,8 @@ static void set_flags_and_fb_idx_for_temporal_mode2(VP9_COMP *const cpi) { if (!spatial_id) { cpi->ref_frame_flags = VP9_LAST_FLAG; } else { + if (spatial_id == cpi->svc.number_spatial_layers - 1) + cpi->ext_refresh_alt_ref_frame = 0; cpi->ref_frame_flags = VP9_LAST_FLAG | VP9_GOLD_FLAG; } }