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.
This commit is contained in:
parent
b71d13be82
commit
d67231312e
Notes:
sideshowbarker
2024-07-17 06:07:06 +09:00
Author: https://github.com/Zaggy1024 Commit: https://github.com/SerenityOS/serenity/commit/d67231312e Pull-request: https://github.com/SerenityOS/serenity/pull/15363 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/FireFox317 Reviewed-by: https://github.com/MacDue Reviewed-by: https://github.com/davidot
4 changed files with 47 additions and 0 deletions
|
@ -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)
|
||||
|
|
9
Tests/LibVideo/CMakeLists.txt
Normal file
9
Tests/LibVideo/CMakeLists.txt
Normal file
|
@ -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)
|
37
Tests/LibVideo/TestVP9Decode.cpp
Normal file
37
Tests/LibVideo/TestVP9Decode.cpp
Normal file
|
@ -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);
|
||||
}
|
BIN
Tests/LibVideo/vp9_in_webm.webm
Normal file
BIN
Tests/LibVideo/vp9_in_webm.webm
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue