Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 jpeg-xl (0.8.2-1) experimental; urgency=medium
 .
   * New upstream version 0.8.2
     * Fixes CVE-2023-0645 / CVE-2023-35790. Closes: #1034722
   * d/patches: Remove failing tests on BE arches. Closes: #1029698
Author: Mathieu Malaterre <malat@debian.org>
Bug-Debian: https://bugs.debian.org/1029698
Bug-Debian: https://bugs.debian.org/1034722

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-05-21

--- jpeg-xl-0.8.2.orig/lib/extras/dec/decode.cc
+++ jpeg-xl-0.8.2/lib/extras/dec/decode.cc
@@ -102,6 +102,12 @@ Status DecodeBytes(const Span<const uint
   } else if (DecodeImagePNM(bytes, color_hints, constraints, ppf)) {
     codec = Codec::kPNM;
   }
+  JXLDecompressParams dparams = {};
+  size_t decoded_bytes;
+  if (DecodeImageJXL(bytes.data(), bytes.size(), dparams, &decoded_bytes,
+                     ppf)) {
+    return Codec::kJXL;
+  }
 #if JPEGXL_ENABLE_GIF
   else if (DecodeImageGIF(bytes, color_hints, constraints, ppf)) {
     codec = Codec::kGIF;
--- jpeg-xl-0.8.2.orig/tools/cjxl_main.cc
+++ jpeg-xl-0.8.2/tools/cjxl_main.cc
@@ -556,57 +556,6 @@ bool IsJPG(const std::vector<uint8_t>& i
           image_data[1] == 0xD8);
 }
 
-// TODO(tfish): Replace with non-C-API library function.
-// Implementation is in extras/.
-jxl::Status GetPixeldata(const std::vector<uint8_t>& image_data,
-                         const jxl::extras::ColorHints& color_hints,
-                         jxl::extras::PackedPixelFile& ppf,
-                         jxl::extras::Codec& codec) {
-  // Any valid encoding is larger (ensures codecs can read the first few bytes).
-  constexpr size_t kMinBytes = 9;
-
-  if (image_data.size() < kMinBytes) return JXL_FAILURE("Input too small.");
-  jxl::Span<const uint8_t> encoded(image_data);
-
-  ppf.info.orientation = JXL_ORIENT_IDENTITY;
-  jxl::SizeConstraints size_constraints;
-
-  const auto choose_codec = [&]() {
-#if JPEGXL_ENABLE_APNG
-    if (jxl::extras::DecodeImageAPNG(encoded, color_hints, size_constraints,
-                                     &ppf)) {
-      return jxl::extras::Codec::kPNG;
-    }
-#endif
-    if (jxl::extras::DecodeImagePGX(encoded, color_hints, size_constraints,
-                                    &ppf)) {
-      return jxl::extras::Codec::kPGX;
-    } else if (jxl::extras::DecodeImagePNM(encoded, color_hints,
-                                           size_constraints, &ppf)) {
-      return jxl::extras::Codec::kPNM;
-    }
-#if JPEGXL_ENABLE_GIF
-    if (jxl::extras::DecodeImageGIF(encoded, color_hints, size_constraints,
-                                    &ppf)) {
-      return jxl::extras::Codec::kGIF;
-    }
-#endif
-#if JPEGXL_ENABLE_JPEG
-    if (jxl::extras::DecodeImageJPG(encoded, color_hints, size_constraints,
-                                    /*output_bit_depth=*/16, &ppf)) {
-      return jxl::extras::Codec::kJPG;
-    }
-#endif
-    // TODO(tfish): Bring back EXR and PSD.
-    return jxl::extras::Codec::kUnknown;
-  };
-  codec = choose_codec();
-  if (codec == jxl::extras::Codec::kUnknown) {
-    return JXL_FAILURE("Codecs failed to decode input.");
-  }
-  return true;
-}
-
 using flag_check_fn = std::function<std::string(int64_t)>;
 using flag_check_float_fn = std::function<std::string(float)>;
 
