ladybird/Tests/LibMedia/TestVP9Decode.cpp
Zaggy1024 f6a4973578 LibMedia: Give frame timestamps to FFmpeg decoders
H.264 in Matroska can have blocks with unordered timestamps. Without
passing these as the presentation timestamp into the FFmpeg decoder,
the frames will not be returned in chronological order.

VideoFrame will now include a timestamp that is used by the
PlaybackManager, rather than assuming that it is the same timestamp
returned by the demuxer.
2024-06-24 12:41:32 -06:00

51 lines
1.2 KiB
C++

/*
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibMedia/Video/VP9/Decoder.h>
#include "TestMediaCommon.h"
static NonnullOwnPtr<Media::VideoDecoder> make_decoder(Media::Matroska::SampleIterator const&)
{
return make<Media::Video::VP9::Decoder>();
}
TEST_CASE(webm_in_vp9)
{
decode_video("./vp9_in_webm.webm"sv, 25, make_decoder);
}
TEST_CASE(vp9_oob_blocks)
{
decode_video("./vp9_oob_blocks.webm"sv, 240, make_decoder);
}
TEST_CASE(vp9_malformed_frame)
{
Array test_inputs = {
"./oss-fuzz-testcase-52630.vp9"sv,
"./oss-fuzz-testcase-53977.vp9"sv,
"./oss-fuzz-testcase-62054.vp9"sv,
"./oss-fuzz-testcase-63182.vp9"sv
};
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
Media::Video::VP9::Decoder vp9_decoder;
auto maybe_decoder_error = vp9_decoder.receive_sample(Duration::zero(), file->bytes());
EXPECT(maybe_decoder_error.is_error());
}
}
BENCHMARK_CASE(vp9_4k)
{
decode_video("./vp9_4k.webm"sv, 2, make_decoder);
}
BENCHMARK_CASE(vp9_clamp_reference_mvs)
{
decode_video("./vp9_clamp_reference_mvs.webm"sv, 92, make_decoder);
}