فهرست منبع

LibGfx/JPEG: Write quantization tables in the zigzag ordering

This is clearly something I missed during the first implementation. The
specification is crystal clear about it: "The quantization elements
shall be specified in zig-zag scan order."

This patch fixes the weird behavior we had when using the quantization
table.
Lucas CHOLLET 2 سال پیش
والد
کامیت
05c8ad4e91
1فایلهای تغییر یافته به همراه2 افزوده شده و 2 حذف شده
  1. 2 2
      Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp

+ 2 - 2
Userland/Libraries/LibGfx/ImageFormats/JPEGWriter.cpp

@@ -398,8 +398,8 @@ ErrorOr<void> add_quantization_table(Stream& stream, QuantizationTable const& ta
     // Pq and Tq
     TRY(stream.write_value<u8>((0 << 4) | table.id));
 
-    for (auto coefficient : table.table)
-        TRY(stream.write_value<u8>(coefficient));
+    for (u8 i = 0; i < 64; ++i)
+        TRY(stream.write_value<u8>(table.table[zigzag_map[i]]));
 
     return {};
 }