Skip to content

Commit

Permalink
LibMedia: Rename LibVideo to LibMedia
Browse files Browse the repository at this point in the history
This change is in preparation for implementing audio codecs into the
library and using audio as timing for video playback.
  • Loading branch information
Zaggy1024 authored and awesomekling committed Jun 19, 2024
1 parent 9bfed9a commit 7c10e1a
Show file tree
Hide file tree
Showing 72 changed files with 197 additions and 179 deletions.
4 changes: 2 additions & 2 deletions Meta/Lagom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,14 @@ set(lagom_standard_libraries
JS
Line
Locale
Media
Protocol
Regex
RIFF
Syntax
TextCodec
Threading
TLS
Video
Wasm
Web
WebSocket
Expand Down Expand Up @@ -526,13 +526,13 @@ if (BUILD_TESTING)
LibCompress
LibGfx
LibLocale
LibMedia
LibTest
LibTextCodec
LibTTF
LibTimeZone
LibUnicode
LibURL
LibVideo
LibWeb
LibWebView
LibXML
Expand Down
2 changes: 1 addition & 1 deletion Meta/Lagom/Contrib/VideoPlayerSDL/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions Meta/Lagom/Contrib/VideoPlayerSDL/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Meta/Lagom/Fuzzers/FuzzMatroskaReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions Meta/Lagom/Fuzzers/FuzzVP9Decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 2 additions & 2 deletions Meta/Lagom/Fuzzers/fuzzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions Tests/LibVideo/CMakeLists.txt → Tests/LibMedia/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

#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;
}));
VERIFY(video_track != 0);

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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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());
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion Userland/Libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions Userland/Libraries/LibMedia/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <AK/Format.h>

namespace Video {
namespace Media {

enum class CodecID : u32 {
Unknown,
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "ColorPrimaries.h"

namespace Video {
namespace Media {

ALWAYS_INLINE constexpr FloatVector3 primaries_to_xyz(FloatVector2 primaries)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading

0 comments on commit 7c10e1a

Please sign in to comment.