Browse Source

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.
Nico Weber 2 years ago
parent
commit
fbc53c1ec3

+ 1 - 0
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

+ 1 - 1
Userland/Libraries/LibVideo/VP9/BooleanDecoder.cpp → 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)

+ 40 - 0
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 };
+};
+
+}

+ 0 - 1
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

+ 3 - 28
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;
 
 }