summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2022-09-25 18:24:07 -0500
committerAndrew Kaster <andrewdkaster@gmail.com>2022-10-09 20:32:40 -0600
commitd67231312eaac90a8f036889547821bcea71ec04 (patch)
tree155dbf1b44497fc0076bc56614b9950eac510067 /Tests
parentb71d13be8280b7df95afb65b59fcfb557caab02e (diff)
downloadserenity-d67231312eaac90a8f036889547821bcea71ec04.zip
LibVideo: Add test to ensure that a VP9 WebM file will decode
This will test decoding of one second of video, to ensure that it can fully decode the entire file.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/LibVideo/CMakeLists.txt9
-rw-r--r--Tests/LibVideo/TestVP9Decode.cpp37
-rw-r--r--Tests/LibVideo/vp9_in_webm.webmbin0 -> 288681 bytes
4 files changed, 47 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 4c60bfbbf8..5133ec1b0b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -21,6 +21,7 @@ add_subdirectory(LibTextCodec)
add_subdirectory(LibThreading)
add_subdirectory(LibTimeZone)
add_subdirectory(LibUnicode)
+add_subdirectory(LibVideo)
add_subdirectory(LibWasm)
add_subdirectory(LibWeb)
add_subdirectory(LibXML)
diff --git a/Tests/LibVideo/CMakeLists.txt b/Tests/LibVideo/CMakeLists.txt
new file mode 100644
index 0000000000..eac688ca94
--- /dev/null
+++ b/Tests/LibVideo/CMakeLists.txt
@@ -0,0 +1,9 @@
+set(TEST_SOURCES
+ TestVP9Decode.cpp
+)
+
+foreach(source IN LISTS TEST_SOURCES)
+ serenity_test("${source}" LibVideo LIBS LibVideo)
+endforeach()
+
+install(FILES vp9_in_webm.webm DESTINATION usr/Tests/LibVideo)
diff --git a/Tests/LibVideo/TestVP9Decode.cpp b/Tests/LibVideo/TestVP9Decode.cpp
new file mode 100644
index 0000000000..eafd8509aa
--- /dev/null
+++ b/Tests/LibVideo/TestVP9Decode.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+
+#include <LibVideo/MatroskaReader.h>
+#include <LibVideo/VP9/Decoder.h>
+
+TEST_CASE(webm_in_vp9)
+{
+ auto matroska_document = Video::MatroskaReader::MatroskaReader::parse_matroska_from_file("./vp9_in_webm.webm"sv);
+ VERIFY(matroska_document);
+ auto video_track_optional = matroska_document->track_for_track_type(Video::TrackEntry::TrackType::Video);
+ VERIFY(video_track_optional.has_value());
+ auto video_track_entry = video_track_optional.value();
+
+ size_t cluster_index, block_index, frame_index;
+ Video::VP9::Decoder vp9_decoder;
+
+ for (cluster_index = 0; cluster_index < matroska_document->clusters().size(); cluster_index++) {
+ auto const& cluster = matroska_document->clusters()[cluster_index];
+ for (block_index = 0; block_index < cluster.blocks().size(); block_index++) {
+ auto const& block = cluster.blocks()[block_index];
+ if (block.track_number() != video_track_entry.track_number())
+ continue;
+
+ for (frame_index = 0; frame_index < block.frames().size(); frame_index++) {
+ MUST(vp9_decoder.decode(block.frames()[frame_index]));
+ }
+ }
+ }
+
+ VERIFY(cluster_index == 1 && block_index == 25 && frame_index == 1);
+}
diff --git a/Tests/LibVideo/vp9_in_webm.webm b/Tests/LibVideo/vp9_in_webm.webm
new file mode 100644
index 0000000000..7db562a22e
--- /dev/null
+++ b/Tests/LibVideo/vp9_in_webm.webm
Binary files differ