tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsJXLDecoder.h (1469B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 *
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_image_decoders_nsJXLDecoder_h
      8 #define mozilla_image_decoders_nsJXLDecoder_h
      9 
     10 #include "Decoder.h"
     11 #include "mp4parse.h"
     12 #include "SurfacePipe.h"
     13 
     14 #include "jxl/decode_cxx.h"
     15 #include "jxl/thread_parallel_runner_cxx.h"
     16 
     17 namespace mozilla::image {
     18 class RasterImage;
     19 
     20 class nsJXLDecoder final : public Decoder {
     21 public:
     22  virtual ~nsJXLDecoder();
     23 
     24  DecoderType GetType() const override { return DecoderType::JXL; }
     25 
     26 protected:
     27  LexerResult DoDecode(SourceBufferIterator& aIterator,
     28                       IResumable* aOnResume) override;
     29 
     30 private:
     31  friend class DecoderFactory;
     32 
     33  // Decoders should only be instantiated via DecoderFactory.
     34  explicit nsJXLDecoder(RasterImage* aImage);
     35 
     36  size_t PreferredThreadCount();
     37 
     38  enum class State { JXL_DATA, FINISHED_JXL_DATA };
     39 
     40  LexerTransition<State> ReadJXLData(const char* aData, size_t aLength);
     41  LexerTransition<State> FinishedJXLData();
     42 
     43  StreamingLexer<State> mLexer;
     44  JxlDecoderPtr mDecoder;
     45  JxlThreadParallelRunnerPtr mParallelRunner;
     46  Vector<uint8_t> mBuffer;
     47  Vector<uint8_t> mOutBuffer;
     48  JxlBasicInfo mInfo{};
     49 };
     50 
     51 }  // namespace mozilla::image
     52 
     53 #endif  // mozilla_image_decoders_nsJXLDecoder_h