2 * Copyright (c) 2016 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
14 #include "test/codec_factory.h"
15 #include "test/decode_test_driver.h"
16 #include "test/ivf_video_source.h"
17 #include "test/test_vectors.h"
18 #include "test/util.h"
22 const unsigned int kNumFrames = 19;
24 class DecodeSvcTest : public ::libvpx_test::DecoderTest,
25 public ::libvpx_test::CodecTestWithParam<const char *> {
27 DecodeSvcTest() : DecoderTest(GET_PARAM(::libvpx_test::kCodecFactoryParam)) {}
28 virtual ~DecodeSvcTest() {}
30 virtual void PreDecodeFrameHook(
31 const libvpx_test::CompressedVideoSource &video,
32 libvpx_test::Decoder *decoder) {
33 if (video.frame_number() == 0)
34 decoder->Control(VP9_DECODE_SVC_SPATIAL_LAYER, spatial_layer_);
37 virtual void DecompressedFrameHook(const vpx_image_t &img,
38 const unsigned int frame_number) {
39 ASSERT_EQ(img.d_w, width_);
40 ASSERT_EQ(img.d_h, height_);
41 total_frames_ = frame_number;
47 unsigned int total_frames_;
50 // SVC test vector is 1280x720, with 3 spatial layers, and 20 frames.
52 // Decode the SVC test vector, which has 3 spatial layers, and decode up to
53 // spatial layer 0. Verify the resolution of each decoded frame and the total
54 // number of frames decoded. This results in 1/4x1/4 resolution (320x180).
55 TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer0) {
56 const std::string filename = GET_PARAM(1);
57 std::unique_ptr<libvpx_test::CompressedVideoSource> video;
58 video.reset(new libvpx_test::IVFVideoSource(filename));
59 ASSERT_NE(video.get(), nullptr);
65 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
66 ASSERT_EQ(total_frames_, kNumFrames);
69 // Decode the SVC test vector, which has 3 spatial layers, and decode up to
70 // spatial layer 1. Verify the resolution of each decoded frame and the total
71 // number of frames decoded. This results in 1/2x1/2 resolution (640x360).
72 TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer1) {
73 const std::string filename = GET_PARAM(1);
74 std::unique_ptr<libvpx_test::CompressedVideoSource> video;
75 video.reset(new libvpx_test::IVFVideoSource(filename));
76 ASSERT_NE(video.get(), nullptr);
82 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
83 ASSERT_EQ(total_frames_, kNumFrames);
86 // Decode the SVC test vector, which has 3 spatial layers, and decode up to
87 // spatial layer 2. Verify the resolution of each decoded frame and the total
88 // number of frames decoded. This results in the full resolution (1280x720).
89 TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer2) {
90 const std::string filename = GET_PARAM(1);
91 std::unique_ptr<libvpx_test::CompressedVideoSource> video;
92 video.reset(new libvpx_test::IVFVideoSource(filename));
93 ASSERT_NE(video.get(), nullptr);
99 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
100 ASSERT_EQ(total_frames_, kNumFrames);
103 // Decode the SVC test vector, which has 3 spatial layers, and decode up to
104 // spatial layer 10. Verify the resolution of each decoded frame and the total
105 // number of frames decoded. This is beyond the number of spatial layers, so
106 // the decoding should result in the full resolution (1280x720).
107 TEST_P(DecodeSvcTest, DecodeSvcTestUpToSpatialLayer10) {
108 const std::string filename = GET_PARAM(1);
109 std::unique_ptr<libvpx_test::CompressedVideoSource> video;
110 video.reset(new libvpx_test::IVFVideoSource(filename));
111 ASSERT_NE(video.get(), nullptr);
117 ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
118 ASSERT_EQ(total_frames_, kNumFrames);
121 VP9_INSTANTIATE_TEST_SUITE(
122 DecodeSvcTest, ::testing::ValuesIn(libvpx_test::kVP9TestVectorsSvc,
123 libvpx_test::kVP9TestVectorsSvc +
124 libvpx_test::kNumVP9TestVectorsSvc));