]> granicus.if.org Git - libvpx/commitdiff
vp9 svc: Add test for intra-only for 1 SL.
authorJerome Jiang <jianj@google.com>
Mon, 9 Jul 2018 20:46:36 +0000 (13:46 -0700)
committerJerome Jiang <jianj@google.com>
Wed, 11 Jul 2018 17:41:55 +0000 (10:41 -0700)
In this case, verify that a key frame is inserted.

Change-Id: I70aa1974de956e657e413a34fd8bbcddf5d20c2c

test/svc_end_to_end_test.cc

index 75f485af77abaaf1760bd514101fc78f27b75940..c90c8751c72df52d676f87404abd69726bb9a2f4 100644 (file)
@@ -110,6 +110,18 @@ class SyncFrameOnePassCbrSvc : public ::svc_test::OnePassCbrSvc,
         pkt->data.frame.spatial_layer_encoded[number_spatial_layers_ - 1] &&
         current_video_frame_ >= frame_to_sync_)
       num_nonref_frames_++;
+
+    if (intra_only_test_ && current_video_frame_ == frame_to_sync_) {
+      // Intra-only frame is only generated for spatial layers > 1 and <= 3,
+      // among other conditions (see constraint in set_intra_only_frame(). If
+      // intra-only is no allowed then encoder will insert key frame instead.
+      const bool key_frame =
+          (pkt->data.frame.flags & VPX_FRAME_IS_KEY) ? true : false;
+      if (number_spatial_layers_ == 1 || number_spatial_layers_ > 3)
+        ASSERT_TRUE(key_frame);
+      else
+        ASSERT_FALSE(key_frame);
+    }
   }
 
   virtual void MismatchHook(const vpx_image_t * /*img1*/,
@@ -357,6 +369,31 @@ TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc3SL3TLSyncFrameIntraOnlyVGA) {
 #endif
 }
 
+// Start decoding from sync frame, insert intra-only on base/qvga layer. Decode
+// all layers. For 1 spatial layer, it inserts a key frame.
+TEST_P(SyncFrameOnePassCbrSvc, OnePassCbrSvc1SL3TLSyncFrameIntraOnlyQVGA) {
+  SetSvcConfig(1, 3);
+  frame_to_start_decode_ = 20;
+  frame_to_sync_ = 20;
+  decode_to_layer_before_sync_ = 0;
+  decode_to_layer_after_sync_ = 0;
+  intra_only_test_ = true;
+
+  // Set up svc layer sync structure.
+  svc_layer_sync_.base_layer_intra_only = 1;
+  svc_layer_sync_.spatial_layer_sync[0] = 1;
+
+  ::libvpx_test::Y4mVideoSource video("niklas_1280_720_30.y4m", 0, 60);
+  cfg_.rc_target_bitrate = 600;
+  AssignLayerBitrates();
+  ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+#if CONFIG_VP9_DECODER
+  // The non-reference frames are expected to be mismatched frames as the
+  // encoder will avoid loopfilter on these frames.
+  EXPECT_EQ(num_nonref_frames_, GetMismatchFrames());
+#endif
+}
+
 VP9_INSTANTIATE_TEST_CASE(SyncFrameOnePassCbrSvc, ::testing::Range(0, 3));
 
 }  // namespace