Bug 1874684 - Part 31: Correctly reject invalid durations in some RoundDuration calls...
[gecko.git] / image / decoders / nsJXLDecoder.h
blob6cde7456ca03f79e74401c1d215b9d50453ebf41
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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/. */
7 #ifndef mozilla_image_decoders_nsJXLDecoder_h
8 #define mozilla_image_decoders_nsJXLDecoder_h
10 #include "Decoder.h"
11 #include "mp4parse.h"
12 #include "SurfacePipe.h"
14 #include "jxl/decode_cxx.h"
15 #include "jxl/thread_parallel_runner_cxx.h"
17 #include "mozilla/Telemetry.h"
19 namespace mozilla::image {
20 class RasterImage;
22 class nsJXLDecoder final : public Decoder {
23 public:
24 virtual ~nsJXLDecoder();
26 DecoderType GetType() const override { return DecoderType::JXL; }
28 protected:
29 LexerResult DoDecode(SourceBufferIterator& aIterator,
30 IResumable* aOnResume) override;
32 private:
33 friend class DecoderFactory;
35 // Decoders should only be instantiated via DecoderFactory.
36 explicit nsJXLDecoder(RasterImage* aImage);
38 size_t PreferredThreadCount();
40 enum class State { JXL_DATA, FINISHED_JXL_DATA };
42 LexerTransition<State> ReadJXLData(const char* aData, size_t aLength);
43 LexerTransition<State> FinishedJXLData();
45 StreamingLexer<State> mLexer;
46 JxlDecoderPtr mDecoder;
47 JxlThreadParallelRunnerPtr mParallelRunner;
48 Vector<uint8_t> mBuffer;
49 Vector<uint8_t> mOutBuffer;
50 JxlBasicInfo mInfo{};
53 } // namespace mozilla::image
55 #endif // mozilla_image_decoders_nsJXLDecoder_h