summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2023-05-26 15:04:31 -0400
committerAndreas Kling <kling@serenityos.org>2023-05-27 05:47:42 +0200
commitfbc53c1ec3bc2f192901fb6c784a7f13ec2b586c (patch)
treeb111ffa84045b9ec9748d940e79ad552c1d387db
parentab5b89eb95964592386f260caa90fbb2e7b83433 (diff)
downloadserenity-fbc53c1ec3bc2f192901fb6c784a7f13ec2b586c.zip
LibGfx+LibVideo: Move VP9/BooleanDecoder to LibGfx/ImageFormats
...and keep a forwarding header around in VP9, so we don't have to update all references to the class there. In time, we probably want to merge LibGfx/ImageDecoders and LibVideo into LibMedia, but for now I need just this class for the lossy webp decoder. So move just it over. No behvior change.
-rw-r--r--Userland/Libraries/LibGfx/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp (renamed from Userland/Libraries/LibVideo/VP9/BooleanDecoder.cpp)2
-rw-r--r--Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h40
-rw-r--r--Userland/Libraries/LibVideo/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibVideo/VP9/BooleanDecoder.h31
5 files changed, 45 insertions, 30 deletions
diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt
index 4e88d5f65f..ab64783da7 100644
--- a/Userland/Libraries/LibGfx/CMakeLists.txt
+++ b/Userland/Libraries/LibGfx/CMakeLists.txt
@@ -33,6 +33,7 @@ set(SOURCES
ICC/WellKnownProfiles.cpp
ImageFormats/BMPLoader.cpp
ImageFormats/BMPWriter.cpp
+ ImageFormats/BooleanDecoder.cpp
ImageFormats/DDSLoader.cpp
ImageFormats/GIFLoader.cpp
ImageFormats/ICOLoader.cpp
diff --git a/Userland/Libraries/LibVideo/VP9/BooleanDecoder.cpp b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp
index facc4c6091..69b3a91d76 100644
--- a/Userland/Libraries/LibVideo/VP9/BooleanDecoder.cpp
+++ b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.cpp
@@ -9,7 +9,7 @@
#include "BooleanDecoder.h"
-namespace Video::VP9 {
+namespace Gfx {
/* 9.2.1 */
ErrorOr<BooleanDecoder> BooleanDecoder::initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes)
diff --git a/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h
new file mode 100644
index 0000000000..d17a4ee2c7
--- /dev/null
+++ b/Userland/Libraries/LibGfx/ImageFormats/BooleanDecoder.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
+ * Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/BitStream.h>
+#include <AK/Error.h>
+#include <AK/Optional.h>
+#include <AK/Types.h>
+
+namespace Gfx {
+
+class BooleanDecoder {
+public:
+ /* (9.2) */
+ static ErrorOr<BooleanDecoder> initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes);
+ ErrorOr<bool> read_bool(u8 probability);
+ ErrorOr<u8> read_literal(u8 bits);
+ ErrorOr<void> finish_decode();
+
+private:
+ BooleanDecoder(MaybeOwned<BigEndianInputBitStream>&& bit_stream, u8 value, u8 range, u64 bits_left)
+ : m_bit_stream(move(bit_stream))
+ , m_value(value)
+ , m_range(range)
+ , m_bits_left(bits_left)
+ {
+ }
+
+ MaybeOwned<BigEndianInputBitStream> m_bit_stream;
+ u8 m_value { 0 };
+ u8 m_range { 0 };
+ u64 m_bits_left { 0 };
+};
+
+}
diff --git a/Userland/Libraries/LibVideo/CMakeLists.txt b/Userland/Libraries/LibVideo/CMakeLists.txt
index 3d1dcb9854..2d52891ac8 100644
--- a/Userland/Libraries/LibVideo/CMakeLists.txt
+++ b/Userland/Libraries/LibVideo/CMakeLists.txt
@@ -6,7 +6,6 @@ set(SOURCES
Containers/Matroska/Reader.cpp
PlaybackManager.cpp
VideoFrame.cpp
- VP9/BooleanDecoder.cpp
VP9/Decoder.cpp
VP9/Parser.cpp
VP9/ProbabilityTables.cpp
diff --git a/Userland/Libraries/LibVideo/VP9/BooleanDecoder.h b/Userland/Libraries/LibVideo/VP9/BooleanDecoder.h
index 5a72f76d70..2c53fc8701 100644
--- a/Userland/Libraries/LibVideo/VP9/BooleanDecoder.h
+++ b/Userland/Libraries/LibVideo/VP9/BooleanDecoder.h
@@ -1,40 +1,15 @@
/*
- * Copyright (c) 2021, Hunter Salyer <thefalsehonesty@gmail.com>
- * Copyright (c) 2022, Gregory Bertilson <zaggy1024@gmail.com>
+ * Copyright (c) 2023, Nico Weber <thakis@chromium.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
-#include <AK/BitStream.h>
-#include <AK/Error.h>
-#include <AK/Optional.h>
-#include <AK/Types.h>
+#include <LibGfx/ImageFormats/BooleanDecoder.h>
namespace Video::VP9 {
-class BooleanDecoder {
-public:
- /* (9.2) */
- static ErrorOr<BooleanDecoder> initialize(MaybeOwned<BigEndianInputBitStream> bit_stream, size_t size_in_bytes);
- ErrorOr<bool> read_bool(u8 probability);
- ErrorOr<u8> read_literal(u8 bits);
- ErrorOr<void> finish_decode();
-
-private:
- BooleanDecoder(MaybeOwned<BigEndianInputBitStream>&& bit_stream, u8 value, u8 range, u64 bits_left)
- : m_bit_stream(move(bit_stream))
- , m_value(value)
- , m_range(range)
- , m_bits_left(bits_left)
- {
- }
-
- MaybeOwned<BigEndianInputBitStream> m_bit_stream;
- u8 m_value { 0 };
- u8 m_range { 0 };
- u64 m_bits_left { 0 };
-};
+using BooleanDecoder = Gfx::BooleanDecoder;
}