Przeglądaj źródła

LibGfx: Rename `JPGLoader` to `JPEGLoader`

The patch also contains modifications on several classes, functions or
files that are related to the `JPGLoader`.

Renaming include:
 - JPGLoader{.h, .cpp}
 - JPGImageDecoderPlugin
 - JPGLoadingContext
 - JPG_DEBUG
 - decode_jpg
 - FuzzJPGLoader.cpp
 - Few string literals or texts
Lucas CHOLLET 2 lat temu
rodzic
commit
856d0202f2

+ 2 - 2
AK/Debug.h.in

@@ -238,8 +238,8 @@
 #cmakedefine01 JOB_DEBUG
 #cmakedefine01 JOB_DEBUG
 #endif
 #endif
 
 
-#ifndef JPG_DEBUG
-#cmakedefine01 JPG_DEBUG
+#ifndef JPEG_DEBUG
+#cmakedefine01 JPEG_DEBUG
 #endif
 #endif
 
 
 #ifndef JS_BYTECODE_DEBUG
 #ifndef JS_BYTECODE_DEBUG

+ 1 - 1
Base/usr/share/man/man1/image2bin.md

@@ -18,6 +18,6 @@ in a raw binary format for further examination.
 ```sh
 ```sh
 # Convert a PNG image to raw bitmap
 # Convert a PNG image to raw bitmap
 $ image2bin example.png > example.bin
 $ image2bin example.png > example.bin
-# Convert a JPG image to raw bitmap
+# Convert a JPEG image to raw bitmap
 $ image2bin another_example.jpg > another_example.bin
 $ image2bin another_example.jpg > another_example.bin
 ```
 ```

+ 1 - 1
Meta/CMake/all_the_debug_macros.cmake

@@ -96,7 +96,7 @@ set(ISO9660_DEBUG ON)
 set(ISO9660_VERY_DEBUG ON)
 set(ISO9660_VERY_DEBUG ON)
 set(ITEM_RECTS_DEBUG ON)
 set(ITEM_RECTS_DEBUG ON)
 set(JOB_DEBUG ON)
 set(JOB_DEBUG ON)
-set(JPG_DEBUG ON)
+set(JPEG_DEBUG ON)
 set(JS_BYTECODE_DEBUG ON)
 set(JS_BYTECODE_DEBUG ON)
 set(JS_MODULE_DEBUG ON)
 set(JS_MODULE_DEBUG ON)
 set(KEYBOARD_DEBUG ON)
 set(KEYBOARD_DEBUG ON)

+ 1 - 1
Meta/Lagom/Fuzzers/CMakeLists.txt

@@ -32,7 +32,7 @@ add_simple_fuzzer(FuzzGzipCompression LibCompress)
 add_simple_fuzzer(FuzzGzipDecompression LibCompress)
 add_simple_fuzzer(FuzzGzipDecompression LibCompress)
 add_simple_fuzzer(FuzzICCProfile LibGfx)
 add_simple_fuzzer(FuzzICCProfile LibGfx)
 add_simple_fuzzer(FuzzICOLoader LibGfx)
 add_simple_fuzzer(FuzzICOLoader LibGfx)
-add_simple_fuzzer(FuzzJPGLoader LibGfx)
+add_simple_fuzzer(FuzzJPEGLoader LibGfx)
 add_simple_fuzzer(FuzzMatroskaReader LibVideo)
 add_simple_fuzzer(FuzzMatroskaReader LibVideo)
 add_simple_fuzzer(FuzzMD5 LibCrypto)
 add_simple_fuzzer(FuzzMD5 LibCrypto)
 add_simple_fuzzer(FuzzMP3Loader LibAudio)
 add_simple_fuzzer(FuzzMP3Loader LibAudio)

+ 2 - 2
Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp → Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp

@@ -4,13 +4,13 @@
  * SPDX-License-Identifier: BSD-2-Clause
  * SPDX-License-Identifier: BSD-2-Clause
  */
  */
 
 
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <stddef.h>
 #include <stddef.h>
 #include <stdint.h>
 #include <stdint.h>
 
 
 extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
 extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
 {
 {
-    auto decoder_or_error = Gfx::JPGImageDecoderPlugin::create({ data, size });
+    auto decoder_or_error = Gfx::JPEGImageDecoderPlugin::create({ data, size });
     if (decoder_or_error.is_error())
     if (decoder_or_error.is_error())
         return 0;
         return 0;
     auto decoder = decoder_or_error.release_value();
     auto decoder = decoder_or_error.release_value();

+ 2 - 2
Tests/LibGfx/TestICCProfile.cpp

@@ -6,7 +6,7 @@
 
 
 #include <LibCore/MappedFile.h>
 #include <LibCore/MappedFile.h>
 #include <LibGfx/ICC/Profile.h>
 #include <LibGfx/ICC/Profile.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibTest/TestCase.h>
 #include <LibTest/TestCase.h>
 
 
@@ -31,7 +31,7 @@ TEST_CASE(png)
 TEST_CASE(jpg)
 TEST_CASE(jpg)
 {
 {
     auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc-v4.jpg"sv)));
     auto file = MUST(Core::MappedFile::map(TEST_INPUT("icc-v4.jpg"sv)));
-    auto jpg = MUST(Gfx::JPGImageDecoderPlugin::create(file->bytes()));
+    auto jpg = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes()));
     EXPECT(jpg->initialize());
     EXPECT(jpg->initialize());
     auto icc_bytes = MUST(jpg->icc_data());
     auto icc_bytes = MUST(jpg->icc_data());
     EXPECT(icc_bytes.has_value());
     EXPECT(icc_bytes.has_value());

+ 3 - 3
Tests/LibGfx/TestImageDecoder.cpp

@@ -11,7 +11,7 @@
 #include <LibGfx/GIFLoader.h>
 #include <LibGfx/GIFLoader.h>
 #include <LibGfx/ICOLoader.h>
 #include <LibGfx/ICOLoader.h>
 #include <LibGfx/ImageDecoder.h>
 #include <LibGfx/ImageDecoder.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <LibGfx/PBMLoader.h>
 #include <LibGfx/PBMLoader.h>
 #include <LibGfx/PGMLoader.h>
 #include <LibGfx/PGMLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibGfx/PNGLoader.h>
@@ -88,8 +88,8 @@ TEST_CASE(test_bmp_embedded_in_ico)
 TEST_CASE(test_jpg)
 TEST_CASE(test_jpg)
 {
 {
     auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgb24.jpg"sv)));
     auto file = MUST(Core::MappedFile::map(TEST_INPUT("rgb24.jpg"sv)));
-    EXPECT(MUST(Gfx::JPGImageDecoderPlugin::sniff(file->bytes())));
-    auto plugin_decoder = MUST(Gfx::JPGImageDecoderPlugin::create(file->bytes()));
+    EXPECT(MUST(Gfx::JPEGImageDecoderPlugin::sniff(file->bytes())));
+    auto plugin_decoder = MUST(Gfx::JPEGImageDecoderPlugin::create(file->bytes()));
     EXPECT(plugin_decoder->initialize());
     EXPECT(plugin_decoder->initialize());
 
 
     EXPECT(plugin_decoder->frame_count());
     EXPECT(plugin_decoder->frame_count());

+ 1 - 1
Userland/Libraries/LibGfx/CMakeLists.txt

@@ -34,7 +34,7 @@ set(SOURCES
     ICC/TagTypes.cpp
     ICC/TagTypes.cpp
     ICOLoader.cpp
     ICOLoader.cpp
     ImageDecoder.cpp
     ImageDecoder.cpp
-    JPGLoader.cpp
+    JPEGLoader.cpp
     PBMLoader.cpp
     PBMLoader.cpp
     PGMLoader.cpp
     PGMLoader.cpp
     PNGLoader.cpp
     PNGLoader.cpp

+ 2 - 2
Userland/Libraries/LibGfx/ImageDecoder.cpp

@@ -10,7 +10,7 @@
 #include <LibGfx/GIFLoader.h>
 #include <LibGfx/GIFLoader.h>
 #include <LibGfx/ICOLoader.h>
 #include <LibGfx/ICOLoader.h>
 #include <LibGfx/ImageDecoder.h>
 #include <LibGfx/ImageDecoder.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <LibGfx/PBMLoader.h>
 #include <LibGfx/PBMLoader.h>
 #include <LibGfx/PGMLoader.h>
 #include <LibGfx/PGMLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibGfx/PNGLoader.h>
@@ -33,7 +33,7 @@ static constexpr ImagePluginInitializer s_initializers[] = {
     { PGMImageDecoderPlugin::sniff, PGMImageDecoderPlugin::create },
     { PGMImageDecoderPlugin::sniff, PGMImageDecoderPlugin::create },
     { PPMImageDecoderPlugin::sniff, PPMImageDecoderPlugin::create },
     { PPMImageDecoderPlugin::sniff, PPMImageDecoderPlugin::create },
     { ICOImageDecoderPlugin::sniff, ICOImageDecoderPlugin::create },
     { ICOImageDecoderPlugin::sniff, ICOImageDecoderPlugin::create },
-    { JPGImageDecoderPlugin::sniff, JPGImageDecoderPlugin::create },
+    { JPEGImageDecoderPlugin::sniff, JPEGImageDecoderPlugin::create },
     { DDSImageDecoderPlugin::sniff, DDSImageDecoderPlugin::create },
     { DDSImageDecoderPlugin::sniff, DDSImageDecoderPlugin::create },
     { QOIImageDecoderPlugin::sniff, QOIImageDecoderPlugin::create },
     { QOIImageDecoderPlugin::sniff, QOIImageDecoderPlugin::create },
 };
 };

+ 86 - 86
Userland/Libraries/LibGfx/JPGLoader.cpp → Userland/Libraries/LibGfx/JPEGLoader.cpp

@@ -14,7 +14,7 @@
 #include <AK/String.h>
 #include <AK/String.h>
 #include <AK/Try.h>
 #include <AK/Try.h>
 #include <AK/Vector.h>
 #include <AK/Vector.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 
 
 #define JPG_INVALID 0X0000
 #define JPG_INVALID 0X0000
 
 
@@ -173,7 +173,7 @@ struct ICCMultiChunkState {
     FixedArray<ByteBuffer> chunks;
     FixedArray<ByteBuffer> chunks;
 };
 };
 
 
-struct JPGLoadingContext {
+struct JPEGLoadingContext {
     enum State {
     enum State {
         NotDecoded = 0,
         NotDecoded = 0,
         Error,
         Error,
@@ -218,13 +218,13 @@ static void generate_huffman_codes(HuffmanTableSpec& table)
 static ErrorOr<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1)
 static ErrorOr<size_t> read_huffman_bits(HuffmanStreamState& hstream, size_t count = 1)
 {
 {
     if (count > (8 * sizeof(size_t))) {
     if (count > (8 * sizeof(size_t))) {
-        dbgln_if(JPG_DEBUG, "Can't read {} bits at once!", count);
+        dbgln_if(JPEG_DEBUG, "Can't read {} bits at once!", count);
         return Error::from_string_literal("Reading too much huffman bits at once");
         return Error::from_string_literal("Reading too much huffman bits at once");
     }
     }
     size_t value = 0;
     size_t value = 0;
     while (count--) {
     while (count--) {
         if (hstream.byte_offset >= hstream.stream.size()) {
         if (hstream.byte_offset >= hstream.stream.size()) {
-            dbgln_if(JPG_DEBUG, "Huffman stream exhausted. This could be an error!");
+            dbgln_if(JPEG_DEBUG, "Huffman stream exhausted. This could be an error!");
             return Error::from_string_literal("Huffman stream exhausted.");
             return Error::from_string_literal("Huffman stream exhausted.");
         }
         }
         u8 current_byte = hstream.stream[hstream.byte_offset];
         u8 current_byte = hstream.stream[hstream.byte_offset];
@@ -253,7 +253,7 @@ static ErrorOr<u8> get_next_symbol(HuffmanStreamState& hstream, HuffmanTableSpec
         }
         }
     }
     }
 
 
-    dbgln_if(JPG_DEBUG, "If you're seeing this...the jpeg decoder needs to support more kinds of JPEGs!");
+    dbgln_if(JPEG_DEBUG, "If you're seeing this...the jpeg decoder needs to support more kinds of JPEGs!");
     return Error::from_string_literal("This kind of JPEG is not yet supported by the decoder");
     return Error::from_string_literal("This kind of JPEG is not yet supported by the decoder");
 }
 }
 
 
@@ -284,7 +284,7 @@ static inline i32* get_component(Macroblock& block, unsigned component)
  * macroblocks that share the chrominance data. Next two iterations (assuming that
  * macroblocks that share the chrominance data. Next two iterations (assuming that
  * we are dealing with three components) will fill up the blocks with chroma data.
  * we are dealing with three components) will fill up the blocks with chroma data.
  */
  */
-static ErrorOr<void> build_macroblocks(JPGLoadingContext& context, Vector<Macroblock>& macroblocks, u32 hcursor, u32 vcursor)
+static ErrorOr<void> build_macroblocks(JPEGLoadingContext& context, Vector<Macroblock>& macroblocks, u32 hcursor, u32 vcursor)
 {
 {
     for (unsigned component_i = 0; component_i < context.component_count; component_i++) {
     for (unsigned component_i = 0; component_i < context.component_count; component_i++) {
         auto& component = context.components[component_i];
         auto& component = context.components[component_i];
@@ -305,7 +305,7 @@ static ErrorOr<void> build_macroblocks(JPGLoadingContext& context, Vector<Macrob
                 // For DC coefficients, symbol encodes the length of the coefficient.
                 // For DC coefficients, symbol encodes the length of the coefficient.
                 auto dc_length = TRY(get_next_symbol(context.huffman_stream, dc_table));
                 auto dc_length = TRY(get_next_symbol(context.huffman_stream, dc_table));
                 if (dc_length > 11) {
                 if (dc_length > 11) {
-                    dbgln_if(JPG_DEBUG, "DC coefficient too long: {}!", dc_length);
+                    dbgln_if(JPEG_DEBUG, "DC coefficient too long: {}!", dc_length);
                     return Error::from_string_literal("DC coefficient too long");
                     return Error::from_string_literal("DC coefficient too long");
                 }
                 }
 
 
@@ -334,13 +334,13 @@ static ErrorOr<void> build_macroblocks(JPGLoadingContext& context, Vector<Macrob
                     j += run_length;
                     j += run_length;
 
 
                     if (j >= 64) {
                     if (j >= 64) {
-                        dbgln_if(JPG_DEBUG, "Run-length exceeded boundaries. Cursor: {}, Skipping: {}!", j, run_length);
+                        dbgln_if(JPEG_DEBUG, "Run-length exceeded boundaries. Cursor: {}, Skipping: {}!", j, run_length);
                         return Error::from_string_literal("Run-length exceeded boundaries");
                         return Error::from_string_literal("Run-length exceeded boundaries");
                     }
                     }
 
 
                     u8 coeff_length = ac_symbol & 0x0F;
                     u8 coeff_length = ac_symbol & 0x0F;
                     if (coeff_length > 10) {
                     if (coeff_length > 10) {
-                        dbgln_if(JPG_DEBUG, "AC coefficient too long: {}!", coeff_length);
+                        dbgln_if(JPEG_DEBUG, "AC coefficient too long: {}!", coeff_length);
                         return Error::from_string_literal("AC coefficient too long");
                         return Error::from_string_literal("AC coefficient too long");
                     }
                     }
 
 
@@ -359,12 +359,12 @@ static ErrorOr<void> build_macroblocks(JPGLoadingContext& context, Vector<Macrob
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& context)
+static ErrorOr<Vector<Macroblock>> decode_huffman_stream(JPEGLoadingContext& context)
 {
 {
     Vector<Macroblock> macroblocks;
     Vector<Macroblock> macroblocks;
     macroblocks.resize(context.mblock_meta.padded_total);
     macroblocks.resize(context.mblock_meta.padded_total);
 
 
-    if constexpr (JPG_DEBUG) {
+    if constexpr (JPEG_DEBUG) {
         dbgln("Image width: {}", context.frame.width);
         dbgln("Image width: {}", context.frame.width);
         dbgln("Image height: {}", context.frame.height);
         dbgln("Image height: {}", context.frame.height);
         dbgln("Macroblocks in a row: {}", context.mblock_meta.hpadded_count);
         dbgln("Macroblocks in a row: {}", context.mblock_meta.hpadded_count);
@@ -403,7 +403,7 @@ static ErrorOr<Vector<Macroblock>> decode_huffman_stream(JPGLoadingContext& cont
             }
             }
 
 
             if (auto result = build_macroblocks(context, macroblocks, hcursor, vcursor); result.is_error()) {
             if (auto result = build_macroblocks(context, macroblocks, hcursor, vcursor); result.is_error()) {
-                if constexpr (JPG_DEBUG) {
+                if constexpr (JPEG_DEBUG) {
                     dbgln("Failed to build Macroblock {}", i);
                     dbgln("Failed to build Macroblock {}", i);
                     dbgln("Huffman stream byte offset {}", context.huffman_stream.byte_offset);
                     dbgln("Huffman stream byte offset {}", context.huffman_stream.byte_offset);
                     dbgln("Huffman stream bit offset {}", context.huffman_stream.bit_offset);
                     dbgln("Huffman stream bit offset {}", context.huffman_stream.bit_offset);
@@ -430,7 +430,7 @@ static inline bool is_valid_marker(const Marker marker)
     if (marker >= JPG_APPN0 && marker <= JPG_APPNF) {
     if (marker >= JPG_APPN0 && marker <= JPG_APPNF) {
 
 
         if (marker != JPG_APPN0)
         if (marker != JPG_APPN0)
-            dbgln_if(JPG_DEBUG, "{:#04x} not supported yet. The decoder may fail!", marker);
+            dbgln_if(JPEG_DEBUG, "{:#04x} not supported yet. The decoder may fail!", marker);
         return true;
         return true;
     }
     }
     if (marker >= JPG_RESERVED1 && marker <= JPG_RESERVEDD)
     if (marker >= JPG_RESERVED1 && marker <= JPG_RESERVEDD)
@@ -452,7 +452,7 @@ static inline bool is_valid_marker(const Marker marker)
 
 
     if (marker >= 0xFFC0 && marker <= 0xFFCF) {
     if (marker >= 0xFFC0 && marker <= 0xFFCF) {
         if (marker != 0xFFC4 && marker != 0xFFC8 && marker != 0xFFCC) {
         if (marker != 0xFFC4 && marker != 0xFFC8 && marker != 0xFFCC) {
-            dbgln_if(JPG_DEBUG, "Decoding this frame-type (SOF{}) is not currently supported. Decoder will fail!", marker & 0xf);
+            dbgln_if(JPEG_DEBUG, "Decoding this frame-type (SOF{}) is not currently supported. Decoder will fail!", marker & 0xf);
             return false;
             return false;
         }
         }
     }
     }
@@ -477,10 +477,10 @@ static inline ErrorOr<Marker> read_marker_at_cursor(Stream& stream)
     return is_valid_marker(marker) ? marker : JPG_INVALID;
     return is_valid_marker(marker) ? marker : JPG_INVALID;
 }
 }
 
 
-static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
-    if (context.state < JPGLoadingContext::State::FrameDecoded) {
-        dbgln_if(JPG_DEBUG, "{}: SOS found before reading a SOF!", TRY(stream.tell()));
+    if (context.state < JPEGLoadingContext::State::FrameDecoded) {
+        dbgln_if(JPEG_DEBUG, "{}: SOS found before reading a SOF!", TRY(stream.tell()));
         return Error::from_string_literal("SOS found before reading a SOF");
         return Error::from_string_literal("SOS found before reading a SOF");
     }
     }
 
 
@@ -488,7 +488,7 @@ static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPGLoadingCo
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
     u8 component_count = TRY(stream.read_value<u8>());
     u8 component_count = TRY(stream.read_value<u8>());
     if (component_count != context.component_count) {
     if (component_count != context.component_count) {
-        dbgln_if(JPG_DEBUG, "{}: Unsupported number of components: {}!", TRY(stream.tell()), component_count);
+        dbgln_if(JPEG_DEBUG, "{}: Unsupported number of components: {}!", TRY(stream.tell()), component_count);
         return Error::from_string_literal("Unsupported number of components");
         return Error::from_string_literal("Unsupported number of components");
     }
     }
 
 
@@ -507,17 +507,17 @@ static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPGLoadingCo
         component.ac_destination_id = table_ids & 0x0F;
         component.ac_destination_id = table_ids & 0x0F;
 
 
         if (context.dc_tables.size() != context.ac_tables.size()) {
         if (context.dc_tables.size() != context.ac_tables.size()) {
-            dbgln_if(JPG_DEBUG, "{}: DC & AC table count mismatch!", TRY(stream.tell()));
+            dbgln_if(JPEG_DEBUG, "{}: DC & AC table count mismatch!", TRY(stream.tell()));
             return Error::from_string_literal("DC & AC table count mismatch");
             return Error::from_string_literal("DC & AC table count mismatch");
         }
         }
 
 
         if (!context.dc_tables.contains(component.dc_destination_id)) {
         if (!context.dc_tables.contains(component.dc_destination_id)) {
-            dbgln_if(JPG_DEBUG, "DC table (id: {}) does not exist!", component.dc_destination_id);
+            dbgln_if(JPEG_DEBUG, "DC table (id: {}) does not exist!", component.dc_destination_id);
             return Error::from_string_literal("DC table does not exist");
             return Error::from_string_literal("DC table does not exist");
         }
         }
 
 
         if (!context.ac_tables.contains(component.ac_destination_id)) {
         if (!context.ac_tables.contains(component.ac_destination_id)) {
-            dbgln_if(JPG_DEBUG, "AC table (id: {}) does not exist!", component.ac_destination_id);
+            dbgln_if(JPEG_DEBUG, "AC table (id: {}) does not exist!", component.ac_destination_id);
             return Error::from_string_literal("AC table does not exist");
             return Error::from_string_literal("AC table does not exist");
         }
         }
     }
     }
@@ -528,7 +528,7 @@ static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPGLoadingCo
 
 
     // The three values should be fixed for baseline JPEGs utilizing sequential DCT.
     // The three values should be fixed for baseline JPEGs utilizing sequential DCT.
     if (spectral_selection_start != 0 || spectral_selection_end != 63 || successive_approximation != 0) {
     if (spectral_selection_start != 0 || spectral_selection_end != 63 || successive_approximation != 0) {
-        dbgln_if(JPG_DEBUG, "{}: ERROR! Start of Selection: {}, End of Selection: {}, Successive Approximation: {}!",
+        dbgln_if(JPEG_DEBUG, "{}: ERROR! Start of Selection: {}, End of Selection: {}, Successive Approximation: {}!",
             TRY(stream.tell()),
             TRY(stream.tell()),
             spectral_selection_start,
             spectral_selection_start,
             spectral_selection_end,
             spectral_selection_end,
@@ -538,18 +538,18 @@ static ErrorOr<void> read_start_of_scan(AK::SeekableStream& stream, JPGLoadingCo
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> read_reset_marker(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> read_reset_marker(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
     u16 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>()) - 2;
     u16 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>()) - 2;
     if (bytes_to_read != 2) {
     if (bytes_to_read != 2) {
-        dbgln_if(JPG_DEBUG, "{}: Malformed reset marker found!", TRY(stream.tell()));
+        dbgln_if(JPEG_DEBUG, "{}: Malformed reset marker found!", TRY(stream.tell()));
         return Error::from_string_literal("Malformed reset marker found");
         return Error::from_string_literal("Malformed reset marker found");
     }
     }
     context.dc_reset_interval = TRY(stream.read_value<BigEndian<u16>>());
     context.dc_reset_interval = TRY(stream.read_value<BigEndian<u16>>());
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> read_huffman_table(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> read_huffman_table(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>());
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>());
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
@@ -560,11 +560,11 @@ static ErrorOr<void> read_huffman_table(AK::SeekableStream& stream, JPGLoadingCo
         u8 table_type = table_info >> 4;
         u8 table_type = table_info >> 4;
         u8 table_destination_id = table_info & 0x0F;
         u8 table_destination_id = table_info & 0x0F;
         if (table_type > 1) {
         if (table_type > 1) {
-            dbgln_if(JPG_DEBUG, "{}: Unrecognized huffman table: {}!", TRY(stream.tell()), table_type);
+            dbgln_if(JPEG_DEBUG, "{}: Unrecognized huffman table: {}!", TRY(stream.tell()), table_type);
             return Error::from_string_literal("Unrecognized huffman table");
             return Error::from_string_literal("Unrecognized huffman table");
         }
         }
         if (table_destination_id > 1) {
         if (table_destination_id > 1) {
-            dbgln_if(JPG_DEBUG, "{}: Invalid huffman table destination id: {}!", TRY(stream.tell()), table_destination_id);
+            dbgln_if(JPEG_DEBUG, "{}: Invalid huffman table destination id: {}!", TRY(stream.tell()), table_destination_id);
             return Error::from_string_literal("Invalid huffman table destination id");
             return Error::from_string_literal("Invalid huffman table destination id");
         }
         }
 
 
@@ -595,13 +595,13 @@ static ErrorOr<void> read_huffman_table(AK::SeekableStream& stream, JPGLoadingCo
     }
     }
 
 
     if (bytes_to_read != 0) {
     if (bytes_to_read != 0) {
-        dbgln_if(JPG_DEBUG, "{}: Extra bytes detected in huffman header!", TRY(stream.tell()));
+        dbgln_if(JPEG_DEBUG, "{}: Extra bytes detected in huffman header!", TRY(stream.tell()));
         return Error::from_string_literal("Extra bytes detected in huffman header");
         return Error::from_string_literal("Extra bytes detected in huffman header");
     }
     }
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> read_icc_profile(SeekableStream& stream, JPGLoadingContext& context, int bytes_to_read)
+static ErrorOr<void> read_icc_profile(SeekableStream& stream, JPEGLoadingContext& context, int bytes_to_read)
 {
 {
     if (bytes_to_read <= 2)
     if (bytes_to_read <= 2)
         return Error::from_string_literal("icc marker too small");
         return Error::from_string_literal("icc marker too small");
@@ -659,7 +659,7 @@ static ErrorOr<void> read_icc_profile(SeekableStream& stream, JPGLoadingContext&
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> read_app_marker(SeekableStream& stream, JPGLoadingContext& context, int app_marker_number)
+static ErrorOr<void> read_app_marker(SeekableStream& stream, JPEGLoadingContext& context, int app_marker_number)
 {
 {
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>());
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>());
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
@@ -690,7 +690,7 @@ static ErrorOr<void> read_app_marker(SeekableStream& stream, JPGLoadingContext&
     return stream.discard(bytes_to_read);
     return stream.discard(bytes_to_read);
 }
 }
 
 
-static inline bool validate_luma_and_modify_context(ComponentSpec const& luma, JPGLoadingContext& context)
+static inline bool validate_luma_and_modify_context(ComponentSpec const& luma, JPEGLoadingContext& context)
 {
 {
     if ((luma.hsample_factor == 1 || luma.hsample_factor == 2) && (luma.vsample_factor == 1 || luma.vsample_factor == 2)) {
     if ((luma.hsample_factor == 1 || luma.hsample_factor == 2) && (luma.vsample_factor == 1 || luma.vsample_factor == 2)) {
         context.mblock_meta.hpadded_count += luma.hsample_factor == 1 ? 0 : context.mblock_meta.hcount % 2;
         context.mblock_meta.hpadded_count += luma.hsample_factor == 1 ? 0 : context.mblock_meta.hcount % 2;
@@ -700,7 +700,7 @@ static inline bool validate_luma_and_modify_context(ComponentSpec const& luma, J
         context.hsample_factor = luma.hsample_factor;
         context.hsample_factor = luma.hsample_factor;
         context.vsample_factor = luma.vsample_factor;
         context.vsample_factor = luma.vsample_factor;
 
 
-        if constexpr (JPG_DEBUG) {
+        if constexpr (JPEG_DEBUG) {
             dbgln("Horizontal Subsampling Factor: {}", luma.hsample_factor);
             dbgln("Horizontal Subsampling Factor: {}", luma.hsample_factor);
             dbgln("Vertical Subsampling Factor: {}", luma.vsample_factor);
             dbgln("Vertical Subsampling Factor: {}", luma.vsample_factor);
         }
         }
@@ -710,7 +710,7 @@ static inline bool validate_luma_and_modify_context(ComponentSpec const& luma, J
     return false;
     return false;
 }
 }
 
 
-static inline void set_macroblock_metadata(JPGLoadingContext& context)
+static inline void set_macroblock_metadata(JPEGLoadingContext& context)
 {
 {
     context.mblock_meta.hcount = (context.frame.width + 7) / 8;
     context.mblock_meta.hcount = (context.frame.width + 7) / 8;
     context.mblock_meta.vcount = (context.frame.height + 7) / 8;
     context.mblock_meta.vcount = (context.frame.height + 7) / 8;
@@ -719,10 +719,10 @@ static inline void set_macroblock_metadata(JPGLoadingContext& context)
     context.mblock_meta.total = context.mblock_meta.hcount * context.mblock_meta.vcount;
     context.mblock_meta.total = context.mblock_meta.hcount * context.mblock_meta.vcount;
 }
 }
 
 
-static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
-    if (context.state == JPGLoadingContext::FrameDecoded) {
-        dbgln_if(JPG_DEBUG, "{}: SOF repeated!", TRY(stream.tell()));
+    if (context.state == JPEGLoadingContext::FrameDecoded) {
+        dbgln_if(JPEG_DEBUG, "{}: SOF repeated!", TRY(stream.tell()));
         return Error::from_string_literal("SOF repeated");
         return Error::from_string_literal("SOF repeated");
     }
     }
 
 
@@ -733,14 +733,14 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
 
 
     context.frame.precision = TRY(stream.read_value<u8>());
     context.frame.precision = TRY(stream.read_value<u8>());
     if (context.frame.precision != 8) {
     if (context.frame.precision != 8) {
-        dbgln_if(JPG_DEBUG, "{}: SOF precision != 8!", TRY(stream.tell()));
+        dbgln_if(JPEG_DEBUG, "{}: SOF precision != 8!", TRY(stream.tell()));
         return Error::from_string_literal("SOF precision != 8");
         return Error::from_string_literal("SOF precision != 8");
     }
     }
 
 
     context.frame.height = TRY(stream.read_value<BigEndian<u16>>());
     context.frame.height = TRY(stream.read_value<BigEndian<u16>>());
     context.frame.width = TRY(stream.read_value<BigEndian<u16>>());
     context.frame.width = TRY(stream.read_value<BigEndian<u16>>());
     if (!context.frame.width || !context.frame.height) {
     if (!context.frame.width || !context.frame.height) {
-        dbgln_if(JPG_DEBUG, "{}: ERROR! Image height: {}, Image width: {}!", TRY(stream.tell()), context.frame.height, context.frame.width);
+        dbgln_if(JPEG_DEBUG, "{}: ERROR! Image height: {}, Image width: {}!", TRY(stream.tell()), context.frame.height, context.frame.width);
         return Error::from_string_literal("Image frame height of width null");
         return Error::from_string_literal("Image frame height of width null");
     }
     }
 
 
@@ -753,7 +753,7 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
 
 
     context.component_count = TRY(stream.read_value<u8>());
     context.component_count = TRY(stream.read_value<u8>());
     if (context.component_count != 1 && context.component_count != 3) {
     if (context.component_count != 1 && context.component_count != 3) {
-        dbgln_if(JPG_DEBUG, "{}: Unsupported number of components in SOF: {}!", TRY(stream.tell()), context.component_count);
+        dbgln_if(JPEG_DEBUG, "{}: Unsupported number of components in SOF: {}!", TRY(stream.tell()), context.component_count);
         return Error::from_string_literal("Unsupported number of components in SOF");
         return Error::from_string_literal("Unsupported number of components in SOF");
     }
     }
 
 
@@ -775,7 +775,7 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
             // By convention, downsampling is applied only on chroma components. So we should
             // By convention, downsampling is applied only on chroma components. So we should
             //  hope to see the maximum sampling factor in the luma component.
             //  hope to see the maximum sampling factor in the luma component.
             if (!validate_luma_and_modify_context(component, context)) {
             if (!validate_luma_and_modify_context(component, context)) {
-                dbgln_if(JPG_DEBUG, "{}: Unsupported luma subsampling factors: horizontal: {}, vertical: {}",
+                dbgln_if(JPEG_DEBUG, "{}: Unsupported luma subsampling factors: horizontal: {}, vertical: {}",
                     TRY(stream.tell()),
                     TRY(stream.tell()),
                     component.hsample_factor,
                     component.hsample_factor,
                     component.vsample_factor);
                     component.vsample_factor);
@@ -783,7 +783,7 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
             }
             }
         } else {
         } else {
             if (component.hsample_factor != 1 || component.vsample_factor != 1) {
             if (component.hsample_factor != 1 || component.vsample_factor != 1) {
-                dbgln_if(JPG_DEBUG, "{}: Unsupported chroma subsampling factors: horizontal: {}, vertical: {}",
+                dbgln_if(JPEG_DEBUG, "{}: Unsupported chroma subsampling factors: horizontal: {}, vertical: {}",
                     TRY(stream.tell()),
                     TRY(stream.tell()),
                     component.hsample_factor,
                     component.hsample_factor,
                     component.vsample_factor);
                     component.vsample_factor);
@@ -793,7 +793,7 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
 
 
         component.qtable_id = TRY(stream.read_value<u8>());
         component.qtable_id = TRY(stream.read_value<u8>());
         if (component.qtable_id > 1) {
         if (component.qtable_id > 1) {
-            dbgln_if(JPG_DEBUG, "{}: Unsupported quantization table id: {}!", TRY(stream.tell()), component.qtable_id);
+            dbgln_if(JPEG_DEBUG, "{}: Unsupported quantization table id: {}!", TRY(stream.tell()), component.qtable_id);
             return Error::from_string_literal("Unsupported quantization table id");
             return Error::from_string_literal("Unsupported quantization table id");
         }
         }
 
 
@@ -803,7 +803,7 @@ static ErrorOr<void> read_start_of_frame(AK::SeekableStream& stream, JPGLoadingC
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> read_quantization_table(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> read_quantization_table(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>()) - 2;
     i32 bytes_to_read = TRY(stream.read_value<BigEndian<u16>>()) - 2;
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
     TRY(ensure_bounds_okay(TRY(stream.tell()), bytes_to_read, context.data_size));
@@ -811,12 +811,12 @@ static ErrorOr<void> read_quantization_table(AK::SeekableStream& stream, JPGLoad
         u8 info_byte = TRY(stream.read_value<u8>());
         u8 info_byte = TRY(stream.read_value<u8>());
         u8 element_unit_hint = info_byte >> 4;
         u8 element_unit_hint = info_byte >> 4;
         if (element_unit_hint > 1) {
         if (element_unit_hint > 1) {
-            dbgln_if(JPG_DEBUG, "{}: Unsupported unit hint in quantization table: {}!", TRY(stream.tell()), element_unit_hint);
+            dbgln_if(JPEG_DEBUG, "{}: Unsupported unit hint in quantization table: {}!", TRY(stream.tell()), element_unit_hint);
             return Error::from_string_literal("Unsupported unit hint in quantization table");
             return Error::from_string_literal("Unsupported unit hint in quantization table");
         }
         }
         u8 table_id = info_byte & 0x0F;
         u8 table_id = info_byte & 0x0F;
         if (table_id > 1) {
         if (table_id > 1) {
-            dbgln_if(JPG_DEBUG, "{}: Unsupported quantization table id: {}!", TRY(stream.tell()), table_id);
+            dbgln_if(JPEG_DEBUG, "{}: Unsupported quantization table id: {}!", TRY(stream.tell()), table_id);
             return Error::from_string_literal("Unsupported quantization table id");
             return Error::from_string_literal("Unsupported quantization table id");
         }
         }
         u32* table = table_id == 0 ? context.luma_table : context.chroma_table;
         u32* table = table_id == 0 ? context.luma_table : context.chroma_table;
@@ -832,7 +832,7 @@ static ErrorOr<void> read_quantization_table(AK::SeekableStream& stream, JPGLoad
         bytes_to_read -= 1 + (element_unit_hint == 0 ? 64 : 128);
         bytes_to_read -= 1 + (element_unit_hint == 0 ? 64 : 128);
     }
     }
     if (bytes_to_read != 0) {
     if (bytes_to_read != 0) {
-        dbgln_if(JPG_DEBUG, "{}: Invalid length for one or more quantization tables!", TRY(stream.tell()));
+        dbgln_if(JPEG_DEBUG, "{}: Invalid length for one or more quantization tables!", TRY(stream.tell()));
         return Error::from_string_literal("Invalid length for one or more quantization tables");
         return Error::from_string_literal("Invalid length for one or more quantization tables");
     }
     }
 
 
@@ -846,7 +846,7 @@ static ErrorOr<void> skip_marker_with_length(Stream& stream)
     return {};
     return {};
 }
 }
 
 
-static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macroblocks)
+static void dequantize(JPEGLoadingContext& context, Vector<Macroblock>& macroblocks)
 {
 {
     for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
     for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
         for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
         for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
@@ -867,7 +867,7 @@ static void dequantize(JPGLoadingContext& context, Vector<Macroblock>& macrobloc
     }
     }
 }
 }
 
 
-static void inverse_dct(JPGLoadingContext const& context, Vector<Macroblock>& macroblocks)
+static void inverse_dct(JPEGLoadingContext const& context, Vector<Macroblock>& macroblocks)
 {
 {
     static float const m0 = 2.0f * AK::cos(1.0f / 16.0f * 2.0f * AK::Pi<float>);
     static float const m0 = 2.0f * AK::cos(1.0f / 16.0f * 2.0f * AK::Pi<float>);
     static float const m1 = 2.0f * AK::cos(2.0f / 16.0f * 2.0f * AK::Pi<float>);
     static float const m1 = 2.0f * AK::cos(2.0f / 16.0f * 2.0f * AK::Pi<float>);
@@ -1034,7 +1034,7 @@ static void inverse_dct(JPGLoadingContext const& context, Vector<Macroblock>& ma
     }
     }
 }
 }
 
 
-static void ycbcr_to_rgb(JPGLoadingContext const& context, Vector<Macroblock>& macroblocks)
+static void ycbcr_to_rgb(JPEGLoadingContext const& context, Vector<Macroblock>& macroblocks)
 {
 {
     for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
     for (u32 vcursor = 0; vcursor < context.mblock_meta.vcount; vcursor += context.vsample_factor) {
         for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
         for (u32 hcursor = 0; hcursor < context.mblock_meta.hcount; hcursor += context.hsample_factor) {
@@ -1067,7 +1067,7 @@ static void ycbcr_to_rgb(JPGLoadingContext const& context, Vector<Macroblock>& m
     }
     }
 }
 }
 
 
-static ErrorOr<void> compose_bitmap(JPGLoadingContext& context, Vector<Macroblock> const& macroblocks)
+static ErrorOr<void> compose_bitmap(JPEGLoadingContext& context, Vector<Macroblock> const& macroblocks)
 {
 {
     context.bitmap = TRY(Bitmap::create(BitmapFormat::BGRx8888, { context.frame.width, context.frame.height }));
     context.bitmap = TRY(Bitmap::create(BitmapFormat::BGRx8888, { context.frame.width, context.frame.height }));
 
 
@@ -1087,11 +1087,11 @@ static ErrorOr<void> compose_bitmap(JPGLoadingContext& context, Vector<Macrobloc
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
     auto marker = TRY(read_marker_at_cursor(stream));
     auto marker = TRY(read_marker_at_cursor(stream));
     if (marker != JPG_SOI) {
     if (marker != JPG_SOI) {
-        dbgln_if(JPG_DEBUG, "{}: SOI not found: {:x}!", TRY(stream.tell()), marker);
+        dbgln_if(JPEG_DEBUG, "{}: SOI not found: {:x}!", TRY(stream.tell()), marker);
         return Error::from_string_literal("SOI not found");
         return Error::from_string_literal("SOI not found");
     }
     }
     for (;;) {
     for (;;) {
@@ -1117,7 +1117,7 @@ static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPGLoadingContext&
         case JPG_RST7:
         case JPG_RST7:
         case JPG_SOI:
         case JPG_SOI:
         case JPG_EOI:
         case JPG_EOI:
-            dbgln_if(JPG_DEBUG, "{}: Unexpected marker {:x}!", TRY(stream.tell()), marker);
+            dbgln_if(JPEG_DEBUG, "{}: Unexpected marker {:x}!", TRY(stream.tell()), marker);
             return Error::from_string_literal("Unexpected marker");
             return Error::from_string_literal("Unexpected marker");
         case JPG_APPN0:
         case JPG_APPN0:
         case JPG_APPN1:
         case JPG_APPN1:
@@ -1139,7 +1139,7 @@ static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPGLoadingContext&
             break;
             break;
         case JPG_SOF0:
         case JPG_SOF0:
             TRY(read_start_of_frame(stream, context));
             TRY(read_start_of_frame(stream, context));
-            context.state = JPGLoadingContext::FrameDecoded;
+            context.state = JPEGLoadingContext::FrameDecoded;
             break;
             break;
         case JPG_DQT:
         case JPG_DQT:
             TRY(read_quantization_table(stream, context));
             TRY(read_quantization_table(stream, context));
@@ -1154,7 +1154,7 @@ static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPGLoadingContext&
             return read_start_of_scan(stream, context);
             return read_start_of_scan(stream, context);
         default:
         default:
             if (auto result = skip_marker_with_length(stream); result.is_error()) {
             if (auto result = skip_marker_with_length(stream); result.is_error()) {
-                dbgln_if(JPG_DEBUG, "{}: Error skipping marker: {:x}!", TRY(stream.tell()), marker);
+                dbgln_if(JPEG_DEBUG, "{}: Error skipping marker: {:x}!", TRY(stream.tell()), marker);
                 return result.release_error();
                 return result.release_error();
             }
             }
             break;
             break;
@@ -1164,7 +1164,7 @@ static ErrorOr<void> parse_header(AK::SeekableStream& stream, JPGLoadingContext&
     VERIFY_NOT_REACHED();
     VERIFY_NOT_REACHED();
 }
 }
 
 
-static ErrorOr<void> scan_huffman_stream(AK::SeekableStream& stream, JPGLoadingContext& context)
+static ErrorOr<void> scan_huffman_stream(AK::SeekableStream& stream, JPEGLoadingContext& context)
 {
 {
     u8 last_byte;
     u8 last_byte;
     u8 current_byte = TRY(stream.read_value<u8>());
     u8 current_byte = TRY(stream.read_value<u8>());
@@ -1189,7 +1189,7 @@ static ErrorOr<void> scan_huffman_stream(AK::SeekableStream& stream, JPGLoadingC
                 current_byte = TRY(stream.read_value<u8>());
                 current_byte = TRY(stream.read_value<u8>());
                 continue;
                 continue;
             }
             }
-            dbgln_if(JPG_DEBUG, "{}: Invalid marker: {:x}!", TRY(stream.tell()), marker);
+            dbgln_if(JPEG_DEBUG, "{}: Invalid marker: {:x}!", TRY(stream.tell()), marker);
             return Error::from_string_literal("Invalid marker");
             return Error::from_string_literal("Invalid marker");
         } else {
         } else {
             context.huffman_stream.stream.append(last_byte);
             context.huffman_stream.stream.append(last_byte);
@@ -1199,21 +1199,21 @@ static ErrorOr<void> scan_huffman_stream(AK::SeekableStream& stream, JPGLoadingC
     VERIFY_NOT_REACHED();
     VERIFY_NOT_REACHED();
 }
 }
 
 
-static ErrorOr<void> decode_header(JPGLoadingContext& context)
+static ErrorOr<void> decode_header(JPEGLoadingContext& context)
 {
 {
-    if (context.state < JPGLoadingContext::State::HeaderDecoded) {
+    if (context.state < JPEGLoadingContext::State::HeaderDecoded) {
         context.stream = TRY(try_make<FixedMemoryStream>(ReadonlyBytes { context.data, context.data_size }));
         context.stream = TRY(try_make<FixedMemoryStream>(ReadonlyBytes { context.data, context.data_size }));
 
 
         if (auto result = parse_header(*context.stream, context); result.is_error()) {
         if (auto result = parse_header(*context.stream, context); result.is_error()) {
-            context.state = JPGLoadingContext::State::Error;
+            context.state = JPEGLoadingContext::State::Error;
             return result.release_error();
             return result.release_error();
         }
         }
-        context.state = JPGLoadingContext::State::HeaderDecoded;
+        context.state = JPEGLoadingContext::State::HeaderDecoded;
     }
     }
     return {};
     return {};
 }
 }
 
 
-static ErrorOr<void> decode_jpg(JPGLoadingContext& context)
+static ErrorOr<void> decode_jpeg(JPEGLoadingContext& context)
 {
 {
     TRY(decode_header(context));
     TRY(decode_header(context));
     TRY(scan_huffman_stream(*context.stream, context));
     TRY(scan_huffman_stream(*context.stream, context));
@@ -1226,45 +1226,45 @@ static ErrorOr<void> decode_jpg(JPGLoadingContext& context)
     return {};
     return {};
 }
 }
 
 
-JPGImageDecoderPlugin::JPGImageDecoderPlugin(u8 const* data, size_t size)
+JPEGImageDecoderPlugin::JPEGImageDecoderPlugin(u8 const* data, size_t size)
 {
 {
-    m_context = make<JPGLoadingContext>();
+    m_context = make<JPEGLoadingContext>();
     m_context->data = data;
     m_context->data = data;
     m_context->data_size = size;
     m_context->data_size = size;
     m_context->huffman_stream.stream.ensure_capacity(50 * KiB);
     m_context->huffman_stream.stream.ensure_capacity(50 * KiB);
 }
 }
 
 
-JPGImageDecoderPlugin::~JPGImageDecoderPlugin() = default;
+JPEGImageDecoderPlugin::~JPEGImageDecoderPlugin() = default;
 
 
-IntSize JPGImageDecoderPlugin::size()
+IntSize JPEGImageDecoderPlugin::size()
 {
 {
-    if (m_context->state == JPGLoadingContext::State::Error)
+    if (m_context->state == JPEGLoadingContext::State::Error)
         return {};
         return {};
-    if (m_context->state >= JPGLoadingContext::State::FrameDecoded)
+    if (m_context->state >= JPEGLoadingContext::State::FrameDecoded)
         return { m_context->frame.width, m_context->frame.height };
         return { m_context->frame.width, m_context->frame.height };
 
 
     return {};
     return {};
 }
 }
 
 
-void JPGImageDecoderPlugin::set_volatile()
+void JPEGImageDecoderPlugin::set_volatile()
 {
 {
     if (m_context->bitmap)
     if (m_context->bitmap)
         m_context->bitmap->set_volatile();
         m_context->bitmap->set_volatile();
 }
 }
 
 
-bool JPGImageDecoderPlugin::set_nonvolatile(bool& was_purged)
+bool JPEGImageDecoderPlugin::set_nonvolatile(bool& was_purged)
 {
 {
     if (!m_context->bitmap)
     if (!m_context->bitmap)
         return false;
         return false;
     return m_context->bitmap->set_nonvolatile(was_purged);
     return m_context->bitmap->set_nonvolatile(was_purged);
 }
 }
 
 
-bool JPGImageDecoderPlugin::initialize()
+bool JPEGImageDecoderPlugin::initialize()
 {
 {
     return true;
     return true;
 }
 }
 
 
-ErrorOr<bool> JPGImageDecoderPlugin::sniff(ReadonlyBytes data)
+ErrorOr<bool> JPEGImageDecoderPlugin::sniff(ReadonlyBytes data)
 {
 {
     return data.size() > 3
     return data.size() > 3
         && data.data()[0] == 0xFF
         && data.data()[0] == 0xFF
@@ -1272,46 +1272,46 @@ ErrorOr<bool> JPGImageDecoderPlugin::sniff(ReadonlyBytes data)
         && data.data()[2] == 0xFF;
         && data.data()[2] == 0xFF;
 }
 }
 
 
-ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> JPGImageDecoderPlugin::create(ReadonlyBytes data)
+ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> JPEGImageDecoderPlugin::create(ReadonlyBytes data)
 {
 {
-    return adopt_nonnull_own_or_enomem(new (nothrow) JPGImageDecoderPlugin(data.data(), data.size()));
+    return adopt_nonnull_own_or_enomem(new (nothrow) JPEGImageDecoderPlugin(data.data(), data.size()));
 }
 }
 
 
-bool JPGImageDecoderPlugin::is_animated()
+bool JPEGImageDecoderPlugin::is_animated()
 {
 {
     return false;
     return false;
 }
 }
 
 
-size_t JPGImageDecoderPlugin::loop_count()
+size_t JPEGImageDecoderPlugin::loop_count()
 {
 {
     return 0;
     return 0;
 }
 }
 
 
-size_t JPGImageDecoderPlugin::frame_count()
+size_t JPEGImageDecoderPlugin::frame_count()
 {
 {
     return 1;
     return 1;
 }
 }
 
 
-ErrorOr<ImageFrameDescriptor> JPGImageDecoderPlugin::frame(size_t index)
+ErrorOr<ImageFrameDescriptor> JPEGImageDecoderPlugin::frame(size_t index)
 {
 {
     if (index > 0)
     if (index > 0)
-        return Error::from_string_literal("JPGImageDecoderPlugin: Invalid frame index");
+        return Error::from_string_literal("JPEGImageDecoderPlugin: Invalid frame index");
 
 
-    if (m_context->state == JPGLoadingContext::State::Error)
-        return Error::from_string_literal("JPGImageDecoderPlugin: Decoding failed");
+    if (m_context->state == JPEGLoadingContext::State::Error)
+        return Error::from_string_literal("JPEGImageDecoderPlugin: Decoding failed");
 
 
-    if (m_context->state < JPGLoadingContext::State::BitmapDecoded) {
-        if (auto result = decode_jpg(*m_context); result.is_error()) {
-            m_context->state = JPGLoadingContext::State::Error;
+    if (m_context->state < JPEGLoadingContext::State::BitmapDecoded) {
+        if (auto result = decode_jpeg(*m_context); result.is_error()) {
+            m_context->state = JPEGLoadingContext::State::Error;
             return result.release_error();
             return result.release_error();
         }
         }
-        m_context->state = JPGLoadingContext::State::BitmapDecoded;
+        m_context->state = JPEGLoadingContext::State::BitmapDecoded;
     }
     }
 
 
     return ImageFrameDescriptor { m_context->bitmap, 0 };
     return ImageFrameDescriptor { m_context->bitmap, 0 };
 }
 }
 
 
-ErrorOr<Optional<ReadonlyBytes>> JPGImageDecoderPlugin::icc_data()
+ErrorOr<Optional<ReadonlyBytes>> JPEGImageDecoderPlugin::icc_data()
 {
 {
     TRY(decode_header(*m_context));
     TRY(decode_header(*m_context));
 
 

+ 5 - 5
Userland/Libraries/LibGfx/JPGLoader.h → Userland/Libraries/LibGfx/JPEGLoader.h

@@ -10,14 +10,14 @@
 
 
 namespace Gfx {
 namespace Gfx {
 
 
-struct JPGLoadingContext;
+struct JPEGLoadingContext;
 
 
-class JPGImageDecoderPlugin : public ImageDecoderPlugin {
+class JPEGImageDecoderPlugin : public ImageDecoderPlugin {
 public:
 public:
     static ErrorOr<bool> sniff(ReadonlyBytes);
     static ErrorOr<bool> sniff(ReadonlyBytes);
     static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
     static ErrorOr<NonnullOwnPtr<ImageDecoderPlugin>> create(ReadonlyBytes);
 
 
-    virtual ~JPGImageDecoderPlugin() override;
+    virtual ~JPEGImageDecoderPlugin() override;
     virtual IntSize size() override;
     virtual IntSize size() override;
     virtual void set_volatile() override;
     virtual void set_volatile() override;
     [[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
     [[nodiscard]] virtual bool set_nonvolatile(bool& was_purged) override;
@@ -29,9 +29,9 @@ public:
     virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
     virtual ErrorOr<Optional<ReadonlyBytes>> icc_data() override;
 
 
 private:
 private:
-    JPGImageDecoderPlugin(u8 const*, size_t);
+    JPEGImageDecoderPlugin(u8 const*, size_t);
 
 
-    OwnPtr<JPGLoadingContext> m_context;
+    OwnPtr<JPEGLoadingContext> m_context;
 };
 };
 
 
 }
 }

+ 4 - 4
Userland/Libraries/LibPDF/Filter.cpp

@@ -6,7 +6,7 @@
 
 
 #include <AK/Hex.h>
 #include <AK/Hex.h>
 #include <LibCompress/Deflate.h>
 #include <LibCompress/Deflate.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <LibPDF/CommonNames.h>
 #include <LibPDF/CommonNames.h>
 #include <LibPDF/Filter.h>
 #include <LibPDF/Filter.h>
 
 
@@ -269,14 +269,14 @@ ErrorOr<ByteBuffer> Filter::decode_jbig2(ReadonlyBytes)
 
 
 ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
 ErrorOr<ByteBuffer> Filter::decode_dct(ReadonlyBytes bytes)
 {
 {
-    if (Gfx::JPGImageDecoderPlugin::sniff({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors()) {
-        auto decoder = Gfx::JPGImageDecoderPlugin::create({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors();
+    if (Gfx::JPEGImageDecoderPlugin::sniff({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors()) {
+        auto decoder = Gfx::JPEGImageDecoderPlugin::create({ bytes.data(), bytes.size() }).release_value_but_fixme_should_propagate_errors();
         if (decoder->initialize()) {
         if (decoder->initialize()) {
             auto frame = TRY(decoder->frame(0));
             auto frame = TRY(decoder->frame(0));
             return frame.image->serialize_to_byte_buffer();
             return frame.image->serialize_to_byte_buffer();
         }
         }
     }
     }
-    return AK::Error::from_string_literal("Not a JPG image!");
+    return AK::Error::from_string_literal("Not a JPEG image!");
 };
 };
 
 
 ErrorOr<ByteBuffer> Filter::decode_jpx(ReadonlyBytes)
 ErrorOr<ByteBuffer> Filter::decode_jpx(ReadonlyBytes)

+ 5 - 5
Userland/Services/SpiceAgent/SpiceAgent.cpp

@@ -10,7 +10,7 @@
 #include <LibGfx/BMPLoader.h>
 #include <LibGfx/BMPLoader.h>
 #include <LibGfx/BMPWriter.h>
 #include <LibGfx/BMPWriter.h>
 #include <LibGfx/Bitmap.h>
 #include <LibGfx/Bitmap.h>
-#include <LibGfx/JPGLoader.h>
+#include <LibGfx/JPEGLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibGfx/PNGLoader.h>
 #include <LibGfx/PNGWriter.h>
 #include <LibGfx/PNGWriter.h>
 #include <memory.h>
 #include <memory.h>
@@ -154,10 +154,10 @@ void SpiceAgent::on_message_received()
                         frame_or_error = bmp_decoder->frame(0);
                         frame_or_error = bmp_decoder->frame(0);
                 }
                 }
             } else if (type == ClipboardType::JPG) {
             } else if (type == ClipboardType::JPG) {
-                if (Gfx::JPGImageDecoderPlugin::sniff({ data_buffer.data(), data_buffer.size() }).release_value_but_fixme_should_propagate_errors()) {
-                    auto jpg_decoder = Gfx::JPGImageDecoderPlugin::create({ data_buffer.data(), data_buffer.size() }).release_value_but_fixme_should_propagate_errors();
-                    if (jpg_decoder->initialize())
-                        frame_or_error = jpg_decoder->frame(0);
+                if (Gfx::JPEGImageDecoderPlugin::sniff({ data_buffer.data(), data_buffer.size() }).release_value_but_fixme_should_propagate_errors()) {
+                    auto jpeg_decoder = Gfx::JPEGImageDecoderPlugin::create({ data_buffer.data(), data_buffer.size() }).release_value_but_fixme_should_propagate_errors();
+                    if (jpeg_decoder->initialize())
+                        frame_or_error = jpeg_decoder->frame(0);
                 }
                 }
             } else {
             } else {
                 dbgln("Unknown clipboard type: {}", (u32)type);
                 dbgln("Unknown clipboard type: {}", (u32)type);

+ 3 - 3
Userland/Utilities/test-fuzz.cpp

@@ -17,7 +17,7 @@
     T(GIFLoader)             \
     T(GIFLoader)             \
     T(HttpRequest)           \
     T(HttpRequest)           \
     T(ICOLoader)             \
     T(ICOLoader)             \
-    T(JPGLoader)             \
+    T(JPEGLoader)            \
     T(Js)                    \
     T(Js)                    \
     T(Markdown)              \
     T(Markdown)              \
     T(PBMLoader)             \
     T(PBMLoader)             \
@@ -61,8 +61,8 @@ ENUMERATE_TARGETS(__ENUMERATE_TARGET)
 #include <Meta/Lagom/Fuzzers/FuzzICOLoader.cpp>
 #include <Meta/Lagom/Fuzzers/FuzzICOLoader.cpp>
 #undef LLVMFuzzerTestOneInput
 #undef LLVMFuzzerTestOneInput
 
 
-#define LLVMFuzzerTestOneInput TestJPGLoader
-#include <Meta/Lagom/Fuzzers/FuzzJPGLoader.cpp>
+#define LLVMFuzzerTestOneInput TestJPEGLoader
+#include <Meta/Lagom/Fuzzers/FuzzJPEGLoader.cpp>
 #undef LLVMFuzzerTestOneInput
 #undef LLVMFuzzerTestOneInput
 
 
 #define LLVMFuzzerTestOneInput TestJs
 #define LLVMFuzzerTestOneInput TestJs