LibMedia: Rename LibVideo to LibMedia

This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.
This commit is contained in:
Zaggy1024 2024-06-10 15:04:03 -05:00 committed by Andreas Kling
parent 9bfed9a9ae
commit 7c10e1a08d
Notes: sideshowbarker 2024-07-17 00:53:02 +09:00
72 changed files with 197 additions and 179 deletions

View file

@ -409,6 +409,7 @@ set(lagom_standard_libraries
JS
Line
Locale
Media
Protocol
Regex
RIFF
@ -416,7 +417,6 @@ set(lagom_standard_libraries
TextCodec
Threading
TLS
Video
Wasm
Web
WebSocket
@ -526,13 +526,13 @@ if (BUILD_TESTING)
LibCompress
LibGfx
LibLocale
LibMedia
LibTest
LibTextCodec
LibTTF
LibTimeZone
LibUnicode
LibURL
LibVideo
LibWeb
LibWebView
LibXML

View file

@ -5,4 +5,4 @@ add_executable(VideoPlayerSDL
)
target_include_directories(VideoPlayerSDL PRIVATE ${SDL2_INCLUDE_DIRS})
target_link_libraries(VideoPlayerSDL PRIVATE LibMain LibCore LibGfx LibVideo SDL2::SDL2)
target_link_libraries(VideoPlayerSDL PRIVATE LibMain LibCore LibGfx LibMedia SDL2::SDL2)

View file

@ -9,7 +9,7 @@
#include <LibCore/File.h>
#include <LibCore/MappedFile.h>
#include <LibMain/Main.h>
#include <LibVideo/PlaybackManager.h>
#include <LibMedia/PlaybackManager.h>
#include <SDL2/SDL.h>
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto file = TRY(Core::File::open(filename, Core::File::OpenMode::Read));
auto mapped_file = TRY(Core::MappedFile::map_from_file(move(file), filename));
auto load_file_result = Video::PlaybackManager::from_mapped_file(move(mapped_file));
auto load_file_result = Media::PlaybackManager::from_mapped_file(move(mapped_file));
if (load_file_result.is_error()) {
warnln("Failed to decode file {}", filename);
return 1;

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibVideo/Containers/Matroska/Reader.h>
#include <LibMedia/Containers/Matroska/Reader.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size)
{
AK::set_debug_enabled(false);
auto matroska_reader_result = Video::Matroska::Reader::from_data({ data, size });
auto matroska_reader_result = Media::Matroska::Reader::from_data({ data, size });
if (matroska_reader_result.is_error())
return 0;
(void)matroska_reader_result.value().segment_information();

View file

@ -4,13 +4,13 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibVideo/VP9/Decoder.h>
#include <LibMedia/Video/VP9/Decoder.h>
#include <stddef.h>
extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size)
{
AK::set_debug_enabled(false);
Video::VP9::Decoder vp9_decoder;
Media::Video::VP9::Decoder vp9_decoder;
(void)vp9_decoder.receive_sample({ data, size });
return 0;
}

View file

@ -73,7 +73,7 @@ set(FUZZER_DEPENDENCIES_JPEGLoader LibGfx)
set(FUZZER_DEPENDENCIES_Js LibJS)
set(FUZZER_DEPENDENCIES_LzmaDecompression LibArchive LibCompress)
set(FUZZER_DEPENDENCIES_LzmaRoundtrip LibCompress)
set(FUZZER_DEPENDENCIES_MatroskaReader LibVideo)
set(FUZZER_DEPENDENCIES_MatroskaReader LibMedia)
set(FUZZER_DEPENDENCIES_MD5 LibCrypto)
set(FUZZER_DEPENDENCIES_MP3Loader LibAudio)
set(FUZZER_DEPENDENCIES_PEM LibCrypto)
@ -94,7 +94,7 @@ set(FUZZER_DEPENDENCIES_TIFFLoader LibGfx)
set(FUZZER_DEPENDENCIES_TTF LibGfx)
set(FUZZER_DEPENDENCIES_TinyVGLoader LibGfx)
set(FUZZER_DEPENDENCIES_URL LibURL)
set(FUZZER_DEPENDENCIES_VP9Decoder LibVideo)
set(FUZZER_DEPENDENCIES_VP9Decoder LibMedia)
set(FUZZER_DEPENDENCIES_WasmParser LibWasm)
set(FUZZER_DEPENDENCIES_WAVLoader LibAudio)
set(FUZZER_DEPENDENCIES_WebPLoader LibGfx)

View file

@ -26,7 +26,7 @@ At the moment, many core library support components are inherited from SerenityO
- LibGfx: 2D Graphics Library, Image Decoding and Rendering
- LibArchive: Archive file format support
- LibUnicode, LibLocale: Unicode and locale support
- LibAudio, LibVideo: Audio and video playback
- LibAudio, LibMedia: Audio and video playback
- LibCore: Event loop, OS abstraction layer
- LibIPC: Inter-process communication

View file

@ -13,7 +13,7 @@ add_subdirectory(LibThreading)
add_subdirectory(LibTimeZone)
add_subdirectory(LibUnicode)
add_subdirectory(LibURL)
add_subdirectory(LibVideo)
add_subdirectory(LibMedia)
add_subdirectory(LibWasm)
add_subdirectory(LibWeb)
add_subdirectory(LibWebView)

View file

@ -4,15 +4,15 @@ set(TEST_SOURCES
)
foreach(source IN LISTS TEST_SOURCES)
serenity_test("${source}" LibVideo LIBS LibVideo)
serenity_test("${source}" LibMedia LIBS LibMedia)
endforeach()
install(FILES vp9_in_webm.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_4k.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_clamp_reference_mvs.webm DESTINATION usr/Tests/LibVideo)
install(FILES vp9_oob_blocks.webm DESTINATION usr/Tests/LibVideo)
install(FILES master_elements_containing_crc32.mkv DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-52630.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-53977.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-62054.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES oss-fuzz-testcase-63182.vp9 DESTINATION usr/Tests/LibVideo)
install(FILES vp9_in_webm.webm DESTINATION usr/Tests/LibMedia)
install(FILES vp9_4k.webm DESTINATION usr/Tests/LibMedia)
install(FILES vp9_clamp_reference_mvs.webm DESTINATION usr/Tests/LibMedia)
install(FILES vp9_oob_blocks.webm DESTINATION usr/Tests/LibMedia)
install(FILES master_elements_containing_crc32.mkv DESTINATION usr/Tests/LibMedia)
install(FILES oss-fuzz-testcase-52630.vp9 DESTINATION usr/Tests/LibMedia)
install(FILES oss-fuzz-testcase-53977.vp9 DESTINATION usr/Tests/LibMedia)
install(FILES oss-fuzz-testcase-62054.vp9 DESTINATION usr/Tests/LibMedia)
install(FILES oss-fuzz-testcase-63182.vp9 DESTINATION usr/Tests/LibMedia)

View file

@ -6,13 +6,13 @@
#include <LibTest/TestCase.h>
#include <LibVideo/Containers/Matroska/Reader.h>
#include <LibMedia/Containers/Matroska/Reader.h>
TEST_CASE(master_elements_containing_crc32)
{
auto matroska_reader = MUST(Video::Matroska::Reader::from_file("master_elements_containing_crc32.mkv"sv));
auto matroska_reader = MUST(Media::Matroska::Reader::from_file("master_elements_containing_crc32.mkv"sv));
u64 video_track = 0;
MUST(matroska_reader.for_each_track_of_type(Video::Matroska::TrackEntry::TrackType::Video, [&](Video::Matroska::TrackEntry const& track_entry) -> Video::DecoderErrorOr<IterationDecision> {
MUST(matroska_reader.for_each_track_of_type(Media::Matroska::TrackEntry::TrackType::Video, [&](Media::Matroska::TrackEntry const& track_entry) -> Media::DecoderErrorOr<IterationDecision> {
video_track = track_entry.track_number();
return IterationDecision::Break;
}));

View file

@ -6,14 +6,14 @@
#include <LibTest/TestCase.h>
#include <LibVideo/Containers/Matroska/Reader.h>
#include <LibVideo/VP9/Decoder.h>
#include <LibMedia/Containers/Matroska/Reader.h>
#include <LibMedia/Video/VP9/Decoder.h>
static void decode_video(StringView path, size_t expected_frame_count)
{
auto matroska_reader = MUST(Video::Matroska::Reader::from_file(path));
auto matroska_reader = MUST(Media::Matroska::Reader::from_file(path));
u64 video_track = 0;
MUST(matroska_reader.for_each_track_of_type(Video::Matroska::TrackEntry::TrackType::Video, [&](Video::Matroska::TrackEntry const& track_entry) -> Video::DecoderErrorOr<IterationDecision> {
MUST(matroska_reader.for_each_track_of_type(Media::Matroska::TrackEntry::TrackType::Video, [&](Media::Matroska::TrackEntry const& track_entry) -> Media::DecoderErrorOr<IterationDecision> {
video_track = track_entry.track_number();
return IterationDecision::Break;
}));
@ -21,11 +21,11 @@ static void decode_video(StringView path, size_t expected_frame_count)
auto iterator = MUST(matroska_reader.create_sample_iterator(video_track));
size_t frame_count = 0;
Video::VP9::Decoder vp9_decoder;
Media::Video::VP9::Decoder vp9_decoder;
while (frame_count <= expected_frame_count) {
auto block_result = iterator.next_block();
if (block_result.is_error() && block_result.error().category() == Video::DecoderErrorCategory::EndOfStream) {
if (block_result.is_error() && block_result.error().category() == Media::DecoderErrorCategory::EndOfStream) {
VERIFY(frame_count == expected_frame_count);
return;
}
@ -36,7 +36,7 @@ static void decode_video(StringView path, size_t expected_frame_count)
while (true) {
auto frame_result = vp9_decoder.get_decoded_frame();
if (frame_result.is_error()) {
if (frame_result.error().category() == Video::DecoderErrorCategory::NeedsMoreInput) {
if (frame_result.error().category() == Media::DecoderErrorCategory::NeedsMoreInput) {
break;
}
VERIFY_NOT_REACHED();
@ -70,7 +70,7 @@ TEST_CASE(vp9_malformed_frame)
for (auto test_input : test_inputs) {
auto file = MUST(Core::MappedFile::map(test_input));
Video::VP9::Decoder vp9_decoder;
Media::Video::VP9::Decoder vp9_decoder;
auto maybe_decoder_error = vp9_decoder.receive_sample(file->bytes());
EXPECT(maybe_decoder_error.is_error());
}

View file

@ -33,7 +33,7 @@ add_subdirectory(LibTLS)
add_subdirectory(LibUnicode)
add_subdirectory(LibURL)
add_subdirectory(LibUSBDB)
add_subdirectory(LibVideo)
add_subdirectory(LibMedia)
add_subdirectory(LibWasm)
add_subdirectory(LibWeb)
add_subdirectory(LibWebSocket)

View file

@ -0,0 +1,17 @@
set(SOURCES
Color/ColorConverter.cpp
Color/ColorPrimaries.cpp
Color/TransferCharacteristics.cpp
Containers/Matroska/MatroskaDemuxer.cpp
Containers/Matroska/Reader.cpp
PlaybackManager.cpp
VideoFrame.cpp
Video/VP9/Decoder.cpp
Video/VP9/Parser.cpp
Video/VP9/ProbabilityTables.cpp
Video/VP9/SyntaxElementCounter.cpp
Video/VP9/TreeParser.cpp
)
serenity_lib(LibMedia media)
target_link_libraries(LibMedia PRIVATE LibCore LibIPC LibGfx LibThreading)

View file

@ -8,7 +8,7 @@
#include <AK/Format.h>
namespace Video {
namespace Media {
enum class CodecID : u32 {
Unknown,
@ -34,48 +34,48 @@ enum class CodecID : u32 {
namespace AK {
template<>
struct Formatter<Video::CodecID> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, Video::CodecID value)
struct Formatter<Media::CodecID> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, Media::CodecID value)
{
StringView codec;
switch (value) {
case Video::CodecID::Unknown:
case Media::CodecID::Unknown:
codec = "Unknown"sv;
break;
case Video::CodecID::VP8:
case Media::CodecID::VP8:
codec = "VP8"sv;
break;
case Video::CodecID::VP9:
case Media::CodecID::VP9:
codec = "VP9"sv;
break;
case Video::CodecID::H261:
case Media::CodecID::H261:
codec = "H.261"sv;
break;
case Video::CodecID::H262:
case Media::CodecID::H262:
codec = "H.262"sv;
break;
case Video::CodecID::H263:
case Media::CodecID::H263:
codec = "H.263"sv;
break;
case Video::CodecID::H264:
case Media::CodecID::H264:
codec = "H.264"sv;
break;
case Video::CodecID::H265:
case Media::CodecID::H265:
codec = "H.265"sv;
break;
case Video::CodecID::MPEG1:
case Media::CodecID::MPEG1:
codec = "MPEG1"sv;
break;
case Video::CodecID::AV1:
case Media::CodecID::AV1:
codec = "AV1"sv;
break;
case Video::CodecID::Theora:
case Media::CodecID::Theora:
codec = "Theora"sv;
break;
case Video::CodecID::Vorbis:
case Media::CodecID::Vorbis:
codec = "Vorbis"sv;
break;
case Video::CodecID::Opus:
case Media::CodecID::Opus:
codec = "Opus"sv;
break;
}

View file

@ -8,7 +8,7 @@
#include <AK/StringView.h>
namespace Video {
namespace Media {
// CICP is defined by H.273:
// https://www.itu.int/rec/T-REC-H.273/en

View file

@ -7,12 +7,12 @@
#include <AK/Math.h>
#include <AK/StdLibExtras.h>
#include <LibGfx/Matrix4x4.h>
#include <LibVideo/Color/ColorPrimaries.h>
#include <LibVideo/Color/TransferCharacteristics.h>
#include <LibMedia/Color/ColorPrimaries.h>
#include <LibMedia/Color/TransferCharacteristics.h>
#include "ColorConverter.h"
namespace Video {
namespace Media {
DecoderErrorOr<ColorConverter> ColorConverter::create(u8 bit_depth, CodingIndependentCodePoints input_cicp, CodingIndependentCodePoints output_cicp)
{

View file

@ -10,10 +10,10 @@
#include <AK/Function.h>
#include <LibGfx/Color.h>
#include <LibGfx/Matrix4x4.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/DecoderError.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/DecoderError.h>
namespace Video {
namespace Media {
template<size_t N, size_t Scale = 1>
struct InterpolatedLookupTable {

View file

@ -9,7 +9,7 @@
#include "ColorPrimaries.h"
namespace Video {
namespace Media {
ALWAYS_INLINE constexpr FloatVector3 primaries_to_xyz(FloatVector2 primaries)
{

View file

@ -7,10 +7,10 @@
#pragma once
#include <LibGfx/Matrix3x3.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/DecoderError.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/DecoderError.h>
namespace Video {
namespace Media {
DecoderErrorOr<FloatMatrix3x3> get_conversion_matrix(ColorPrimaries input_primaries, ColorPrimaries output_primaries);

View file

@ -10,7 +10,7 @@
#include "TransferCharacteristics.h"
namespace Video {
namespace Media {
// SDR maximum luminance in candelas per meter squared
constexpr float sdr_max_luminance = 120.0f;

View file

@ -7,9 +7,9 @@
#pragma once
#include <LibGfx/Vector4.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
namespace Video {
namespace Media {
class TransferCharacteristicsConversion {
public:

View file

@ -13,9 +13,9 @@
#include <AK/OwnPtr.h>
#include <AK/Time.h>
#include <AK/Utf8View.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
namespace Video::Matroska {
namespace Media::Matroska {
struct EBMLHeader {
ByteString doc_type;
@ -76,20 +76,20 @@ public:
CodingIndependentCodePoints to_cicp() const
{
Video::VideoFullRangeFlag video_full_range_flag;
VideoFullRangeFlag video_full_range_flag;
switch (range) {
case ColorRange::Full:
video_full_range_flag = Video::VideoFullRangeFlag::Full;
video_full_range_flag = VideoFullRangeFlag::Full;
break;
case ColorRange::Broadcast:
video_full_range_flag = Video::VideoFullRangeFlag::Studio;
video_full_range_flag = VideoFullRangeFlag::Studio;
break;
case ColorRange::Unspecified:
case ColorRange::UseCICP:
// FIXME: Figure out what UseCICP should do here. Matroska specification did not
// seem to explain in the 'colour' section. When this is fixed, change
// replace_code_points_if_specified to match.
video_full_range_flag = Video::VideoFullRangeFlag::Unspecified;
video_full_range_flag = VideoFullRangeFlag::Unspecified;
break;
}

View file

@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "MatroskaDemuxer.h"
#include <AK/Debug.h>
namespace Video::Matroska {
#include "MatroskaDemuxer.h"
namespace Media::Matroska {
DecoderErrorOr<NonnullOwnPtr<MatroskaDemuxer>> MatroskaDemuxer::from_file(StringView filename)
{
@ -136,7 +137,7 @@ DecoderErrorOr<NonnullOwnPtr<Sample>> MatroskaDemuxer::get_next_sample_for_track
status.frame_index = 0;
}
auto cicp = TRY(m_reader.track_for_track_number(track.identifier())).video_track()->color_format.to_cicp();
return make<VideoSample>(status.block->frame(status.frame_index++), cicp, status.block->timestamp());
return make<Video::VideoSample>(status.block->frame(status.frame_index++), cicp, status.block->timestamp());
}
DecoderErrorOr<Duration> MatroskaDemuxer::duration()

View file

@ -7,11 +7,11 @@
#pragma once
#include <AK/HashMap.h>
#include <LibVideo/Containers/Demuxer.h>
#include <LibMedia/Demuxer.h>
#include "Reader.h"
namespace Video::Matroska {
namespace Media::Matroska {
class MatroskaDemuxer final : public Demuxer {
public:

View file

@ -14,7 +14,7 @@
#include "Reader.h"
namespace Video::Matroska {
namespace Media::Matroska {
#define TRY_READ(expression) DECODER_TRY(DecoderErrorCategory::Corrupted, expression)

View file

@ -11,11 +11,11 @@
#include <AK/Optional.h>
#include <AK/OwnPtr.h>
#include <LibCore/MappedFile.h>
#include <LibVideo/DecoderError.h>
#include <LibMedia/DecoderError.h>
#include "Document.h"
namespace Video::Matroska {
namespace Media::Matroska {
class SampleIterator;
class Streamer;

View file

@ -10,10 +10,10 @@
#include <AK/Error.h>
#include <AK/Format.h>
#include <AK/SourceLocation.h>
#include <LibVideo/Forward.h>
#include <LibMedia/Forward.h>
#include <errno.h>
namespace Video {
namespace Media {
template<typename T>
using DecoderErrorOr = ErrorOr<T, DecoderError>;

View file

@ -8,12 +8,13 @@
#include <AK/NonnullOwnPtr.h>
#include <LibCore/EventReceiver.h>
#include <LibVideo/CodecID.h>
#include <LibVideo/DecoderError.h>
#include <LibVideo/Sample.h>
#include <LibVideo/Track.h>
#include <LibMedia/Video/VideoSample.h>
namespace Video {
#include "CodecID.h"
#include "DecoderError.h"
#include "Track.h"
namespace Media {
class Demuxer {
public:
@ -21,12 +22,12 @@ public:
virtual DecoderErrorOr<Vector<Track>> get_tracks_for_type(TrackType type) = 0;
DecoderErrorOr<NonnullOwnPtr<VideoSample>> get_next_video_sample_for_track(Track track)
DecoderErrorOr<NonnullOwnPtr<Video::VideoSample>> get_next_video_sample_for_track(Track track)
{
VERIFY(track.type() == TrackType::Video);
auto sample = TRY(get_next_sample_for_track(track));
VERIFY(sample->is_video_sample());
return sample.release_nonnull<VideoSample>();
return sample.release_nonnull<Video::VideoSample>();
}
virtual DecoderErrorOr<CodecID> get_codec_id_for_track(Track track) = 0;

View file

@ -6,7 +6,7 @@
#pragma once
namespace Video {
namespace Media {
class DecoderError;
class FrameQueueItem;

View file

@ -6,12 +6,12 @@
#include <AK/Format.h>
#include <LibCore/Timer.h>
#include <LibVideo/Containers/Matroska/MatroskaDemuxer.h>
#include <LibVideo/VP9/Decoder.h>
#include <LibMedia/Containers/Matroska/MatroskaDemuxer.h>
#include <LibMedia/Video/VP9/Decoder.h>
#include "PlaybackManager.h"
namespace Video {
namespace Media {
#define TRY_OR_FATAL_ERROR(expression) \
({ \
@ -703,7 +703,7 @@ DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::create(NonnullOw
OwnPtr<VideoDecoder> decoder;
switch (codec_id) {
case CodecID::VP9:
decoder = DECODER_TRY_ALLOC(try_make<VP9::Decoder>());
decoder = DECODER_TRY_ALLOC(try_make<Video::VP9::Decoder>());
break;
default:

View file

@ -13,15 +13,15 @@
#include <AK/Time.h>
#include <LibCore/SharedCircularQueue.h>
#include <LibGfx/Bitmap.h>
#include <LibMedia/Containers/Matroska/Document.h>
#include <LibMedia/Demuxer.h>
#include <LibThreading/ConditionVariable.h>
#include <LibThreading/Mutex.h>
#include <LibThreading/Thread.h>
#include <LibVideo/Containers/Demuxer.h>
#include <LibVideo/Containers/Matroska/Document.h>
#include "VideoDecoder.h"
namespace Video {
namespace Media {
class FrameQueueItem {
public:

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Time.h>
namespace Media {
class Sample {
public:
virtual ~Sample() = default;
virtual bool is_video_sample() const { return false; }
};
}

View file

@ -12,7 +12,7 @@
#include <AK/Types.h>
#include <AK/Variant.h>
namespace Video {
namespace Media {
enum class TrackType : u32 {
Video,
@ -77,6 +77,6 @@ private:
}
template<>
struct AK::Traits<Video::Track> : public DefaultTraits<Video::Track> {
static unsigned hash(Video::Track const& t) { return t.hash(); }
struct AK::Traits<Media::Track> : public DefaultTraits<Media::Track> {
static unsigned hash(Media::Track const& t) { return t.hash(); }
};

View file

@ -8,7 +8,7 @@
#include <LibGfx/ImageFormats/BooleanDecoder.h>
namespace Video::VP9 {
namespace Media::Video::VP9 {
using BooleanDecoder = Gfx::BooleanDecoder;

View file

@ -13,8 +13,8 @@
#include <AK/FixedArray.h>
#include <AK/MemoryStream.h>
#include <LibGfx/Size.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/DecoderError.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/DecoderError.h>
#include "BooleanDecoder.h"
#include "ContextStorage.h"
@ -24,7 +24,7 @@
#include "SyntaxElementCounter.h"
#include "Utilities.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
enum class FrameShowMode {
CreateAndShowNewFrame,

View file

@ -11,13 +11,13 @@
#include <AK/Error.h>
#include <AK/Vector.h>
#include <LibGfx/Size.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include "Enums.h"
#include "LookupTables.h"
#include "MotionVector.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
template<typename T>
struct ReferencePair {

View file

@ -8,7 +8,7 @@
#include <AK/IntegralMath.h>
#include <AK/TypedTransfer.h>
#include <LibGfx/Size.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include "Context.h"
#include "Decoder.h"
@ -18,7 +18,7 @@
# pragma GCC optimize("O3")
#endif
namespace Video::VP9 {
namespace Media::Video::VP9 {
Decoder::Decoder()
: m_parser(make<Parser>(*this))

View file

@ -12,14 +12,14 @@
#include <AK/NonnullOwnPtr.h>
#include <AK/Queue.h>
#include <AK/Span.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/DecoderError.h>
#include <LibVideo/VideoDecoder.h>
#include <LibVideo/VideoFrame.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/DecoderError.h>
#include <LibMedia/VideoDecoder.h>
#include <LibMedia/VideoFrame.h>
#include "Parser.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
class Decoder : public VideoDecoder {
friend class Parser;

View file

@ -9,7 +9,7 @@
#include "Symbols.h"
#include <AK/Types.h>
namespace Video::VP9 {
namespace Media::Video::VP9 {
enum class FrameType {
KeyFrame,

View file

@ -11,7 +11,7 @@
#include "MotionVector.h"
#include "Symbols.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
static constexpr InterpolationFilter literal_to_type[4] = { EightTapSmooth, EightTap, EightTapSharp, Bilinear };
static constexpr TransformSize tx_mode_to_biggest_tx_size[TX_MODES] = { Transform_4x4, Transform_8x8, Transform_16x16, Transform_32x32, Transform_32x32 };

View file

@ -9,7 +9,7 @@
#include <AK/Types.h>
namespace Video::VP9 {
namespace Media::Video::VP9 {
struct MotionVector {
public:

View file

@ -22,7 +22,7 @@
// Beware, threading is unstable in Serenity with smp=on, and performs worse than with it off.
#define VP9_TILE_THREADING
namespace Video::VP9 {
namespace Media::Video::VP9 {
#define TRY_READ(expression) DECODER_TRY(DecoderErrorCategory::Corrupted, expression)

View file

@ -11,9 +11,10 @@
#include <AK/OwnPtr.h>
#include <AK/Span.h>
#include <LibGfx/Size.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/DecoderError.h>
#include <LibMedia/Forward.h>
#include <LibThreading/Forward.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/Forward.h>
#include "ContextStorage.h"
#include "LookupTables.h"
@ -22,7 +23,7 @@
#include "SyntaxElementCounter.h"
#include "TreeParser.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
class Decoder;

View file

@ -7,7 +7,7 @@
#include "ProbabilityTables.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
static constexpr ParetoTable constant_pareto_table = {
{ 3, 86, 128, 6, 86, 23, 88, 29 },

View file

@ -12,7 +12,7 @@
#include "Symbols.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
typedef u8 ParetoTable[128][8];
typedef u8 KfPartitionProbs[PARTITION_CONTEXTS][PARTITION_TYPES - 1];

View file

@ -7,7 +7,7 @@
#pragma once
namespace Video::VP9 {
namespace Media::Video::VP9 {
// FIXME: These should be placed in logical groupings based on the
// context they are used in, and perhaps split into multiple

View file

@ -7,7 +7,7 @@
#include "SyntaxElementCounter.h"
#include <AK/Format.h>
namespace Video::VP9 {
namespace Media::Video::VP9 {
SyntaxElementCounter::SyntaxElementCounter()
{

View file

@ -9,7 +9,7 @@
#include "Symbols.h"
#include <AK/Types.h>
namespace Video::VP9 {
namespace Media::Video::VP9 {
class SyntaxElementCounter final {
public:

View file

@ -14,7 +14,7 @@
#include "TreeParser.h"
#include "Utilities.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
// Parsing of binary trees is handled here, as defined in sections 9.3.
// Each syntax element is defined in its own section for each overarching section listed here:

View file

@ -13,7 +13,7 @@
#include "ProbabilityTables.h"
#include "SyntaxElementCounter.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
class Parser;

View file

@ -12,7 +12,7 @@
#include "LookupTables.h"
namespace Video::VP9 {
namespace Media::Video::VP9 {
// FIXME: Once everything is working, replace this with plain clamp
// since parameter order is different

View file

@ -8,18 +8,12 @@
#include <AK/ByteBuffer.h>
#include <AK/Time.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Sample.h>
namespace Video {
namespace Media::Video {
class Sample {
public:
virtual ~Sample() = default;
virtual bool is_video_sample() const { return false; }
};
class VideoSample : public Sample {
class VideoSample : public Media::Sample {
public:
VideoSample(ReadonlyBytes data, CodingIndependentCodePoints container_cicp, Duration timestamp)
: m_data(data)

View file

@ -10,9 +10,8 @@
#include <AK/NonnullOwnPtr.h>
#include "DecoderError.h"
#include "VideoFrame.h"
namespace Video {
namespace Media {
class VideoDecoder {
public:

View file

@ -6,11 +6,11 @@
#include <AK/NonnullOwnPtr.h>
#include <AK/OwnPtr.h>
#include <LibVideo/Color/ColorConverter.h>
#include <LibMedia/Color/ColorConverter.h>
#include "VideoFrame.h"
namespace Video {
namespace Media {
ErrorOr<NonnullOwnPtr<SubsampledYUVFrame>> SubsampledYUVFrame::try_create(
Gfx::Size<u32> size,

View file

@ -10,10 +10,11 @@
#include <AK/FixedArray.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/Size.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibVideo/DecoderError.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
namespace Video {
#include "DecoderError.h"
namespace Media {
class VideoFrame {

View file

@ -1,17 +0,0 @@
set(SOURCES
Color/ColorConverter.cpp
Color/ColorPrimaries.cpp
Color/TransferCharacteristics.cpp
Containers/Matroska/MatroskaDemuxer.cpp
Containers/Matroska/Reader.cpp
PlaybackManager.cpp
VideoFrame.cpp
VP9/Decoder.cpp
VP9/Parser.cpp
VP9/ProbabilityTables.cpp
VP9/SyntaxElementCounter.cpp
VP9/TreeParser.cpp
)
serenity_lib(LibVideo video)
target_link_libraries(LibVideo PRIVATE LibAudio LibCore LibIPC LibGfx LibThreading)

View file

@ -754,7 +754,7 @@ find_package(unofficial-skia CONFIG REQUIRED)
serenity_lib(LibWeb web)
target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibHTTP LibGfx LibIPC LibLocale LibRegex LibSyntax LibTextCodec LibUnicode LibAudio LibVideo LibWasm LibXML LibIDL LibURL LibTLS unofficial::skia::skia)
target_link_libraries(LibWeb PRIVATE LibCore LibCrypto LibJS LibHTTP LibGfx LibIPC LibLocale LibRegex LibSyntax LibTextCodec LibUnicode LibAudio LibMedia LibWasm LibXML LibIDL LibURL LibTLS unofficial::skia::skia)
if (HAS_ACCELERATED_GRAPHICS)
target_link_libraries(LibWeb PRIVATE ${ACCEL_GFX_LIBS})

View file

@ -7,7 +7,7 @@
#include <LibAudio/Loader.h>
#include <LibJS/Runtime/Promise.h>
#include <LibVideo/PlaybackManager.h>
#include <LibMedia/PlaybackManager.h>
#include <LibWeb/Bindings/HTMLMediaElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/DOM/Document.h>
@ -1068,7 +1068,7 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void(Str
auto& vm = realm.vm();
auto audio_loader = Audio::Loader::create(m_media_data.bytes());
auto playback_manager = Video::PlaybackManager::from_data(m_media_data);
auto playback_manager = Media::PlaybackManager::from_data(m_media_data);
// -> If the media data cannot be fetched at all, due to network errors, causing the user agent to give up trying to fetch the resource
// -> If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all

View file

@ -9,8 +9,8 @@
#include <LibGfx/Bitmap.h>
#include <LibJS/Runtime/Realm.h>
#include <LibJS/Runtime/VM.h>
#include <LibVideo/PlaybackManager.h>
#include <LibVideo/Track.h>
#include <LibMedia/PlaybackManager.h>
#include <LibMedia/Track.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/VideoTrackPrototype.h>
#include <LibWeb/DOM/Event.h>
@ -26,7 +26,7 @@ JS_DEFINE_ALLOCATOR(VideoTrack);
static IDAllocator s_video_track_id_allocator;
VideoTrack::VideoTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> media_element, NonnullOwnPtr<Video::PlaybackManager> playback_manager)
VideoTrack::VideoTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> media_element, NonnullOwnPtr<Media::PlaybackManager> playback_manager)
: PlatformObject(realm)
, m_media_element(media_element)
, m_playback_manager(move(playback_manager))
@ -42,7 +42,7 @@ VideoTrack::VideoTrack(JS::Realm& realm, JS::NonnullGCPtr<HTMLMediaElement> medi
m_playback_manager->on_playback_state_change = [this]() {
switch (m_playback_manager->get_state()) {
case Video::PlaybackState::Stopped: {
case Media::PlaybackState::Stopped: {
auto playback_position_ms = static_cast<double>(duration().to_milliseconds());
m_media_element->set_current_playback_position(playback_position_ms / 1000.0);
break;
@ -117,10 +117,10 @@ void VideoTrack::seek(Duration position, MediaSeekMode seek_mode)
{
switch (seek_mode) {
case MediaSeekMode::Accurate:
m_playback_manager->seek_to_timestamp(position, Video::PlaybackManager::SeekMode::Accurate);
m_playback_manager->seek_to_timestamp(position, Media::PlaybackManager::SeekMode::Accurate);
break;
case MediaSeekMode::ApproximateForSpeed:
m_playback_manager->seek_to_timestamp(position, Video::PlaybackManager::SeekMode::Fast);
m_playback_manager->seek_to_timestamp(position, Media::PlaybackManager::SeekMode::Fast);
break;
}
}

View file

@ -9,7 +9,7 @@
#include <AK/String.h>
#include <AK/Time.h>
#include <LibGfx/Forward.h>
#include <LibVideo/Forward.h>
#include <LibMedia/Forward.h>
#include <LibWeb/Bindings/PlatformObject.h>
namespace Web::HTML {
@ -43,7 +43,7 @@ public:
void set_selected(bool selected);
private:
VideoTrack(JS::Realm&, JS::NonnullGCPtr<HTMLMediaElement>, NonnullOwnPtr<Video::PlaybackManager>);
VideoTrack(JS::Realm&, JS::NonnullGCPtr<HTMLMediaElement>, NonnullOwnPtr<Media::PlaybackManager>);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
@ -66,7 +66,7 @@ private:
JS::NonnullGCPtr<HTMLMediaElement> m_media_element;
JS::GCPtr<VideoTrackList> m_video_track_list;
NonnullOwnPtr<Video::PlaybackManager> m_playback_manager;
NonnullOwnPtr<Media::PlaybackManager> m_playback_manager;
};
}

View file

@ -35,7 +35,7 @@ target_link_libraries(aconv PRIVATE LibAudio LibFileSystem)
target_link_libraries(animation PRIVATE LibGfx)
target_link_libraries(gzip PRIVATE LibCompress)
target_link_libraries(headless-browser PRIVATE LibCrypto LibFileSystem LibGfx LibHTTP LibImageDecoderClient LibTLS LibWeb LibWebView LibWebSocket LibIPC LibJS LibDiff LibURL)
target_link_libraries(icc PRIVATE LibGfx LibVideo LibURL)
target_link_libraries(icc PRIVATE LibGfx LibMedia LibURL)
target_link_libraries(image PRIVATE LibGfx)
target_link_libraries(js PRIVATE LibCrypto LibJS LibLine LibLocale LibTextCodec)
target_link_libraries(lzcat PRIVATE LibCompress)

View file

@ -17,7 +17,7 @@
#include <LibGfx/ICC/Tags.h>
#include <LibGfx/ICC/WellKnownProfiles.h>
#include <LibGfx/ImageFormats/ImageDecoder.h>
#include <LibVideo/Color/CodingIndependentCodePoints.h>
#include <LibMedia/Color/CodingIndependentCodePoints.h>
template<class T>
static ErrorOr<String> hyperlink(URL::URL const& target, T const& label)
@ -406,13 +406,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else if (tag_data->type() == Gfx::ICC::CicpTagData::Type) {
auto& cicp = static_cast<Gfx::ICC::CicpTagData&>(*tag_data);
outln(" color primaries: {} - {}", cicp.color_primaries(),
Video::color_primaries_to_string((Video::ColorPrimaries)cicp.color_primaries()));
Media::color_primaries_to_string((Media::ColorPrimaries)cicp.color_primaries()));
outln(" transfer characteristics: {} - {}", cicp.transfer_characteristics(),
Video::transfer_characteristics_to_string((Video::TransferCharacteristics)cicp.transfer_characteristics()));
Media::transfer_characteristics_to_string((Media::TransferCharacteristics)cicp.transfer_characteristics()));
outln(" matrix coefficients: {} - {}", cicp.matrix_coefficients(),
Video::matrix_coefficients_to_string((Video::MatrixCoefficients)cicp.matrix_coefficients()));
Media::matrix_coefficients_to_string((Media::MatrixCoefficients)cicp.matrix_coefficients()));
outln(" video full range flag: {} - {}", cicp.video_full_range_flag(),
Video::video_full_range_flag_to_string((Video::VideoFullRangeFlag)cicp.video_full_range_flag()));
Media::video_full_range_flag_to_string((Media::VideoFullRangeFlag)cicp.video_full_range_flag()));
} else if (tag_data->type() == Gfx::ICC::CurveTagData::Type) {
TRY(out_curve_tag(*tag_data, /*indent=*/4));
} else if (tag_data->type() == Gfx::ICC::Lut16TagData::Type) {