Skip to content

Commit cb007fb

Browse files
zondsaschanaz
authored andcommitted
Bug 1986393 - Remove the old C++ JXL decoder. r=tnikkel,saschanaz,sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D263345
1 parent c3bd8cb commit cb007fb

File tree

193 files changed

+8
-144122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+8
-144122
lines changed

config/external/moz.build

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ if not CONFIG["MOZ_SYSTEM_WEBP"]:
5555

5656
external_dirs += ["media/ffvpx"]
5757

58-
if CONFIG["MOZ_JXL"]:
59-
external_dirs += ["media/libjxl", "media/highway"]
60-
6158
external_dirs += [
6259
"media/libcubeb",
6360
"media/libmkv",

image/decoders/nsJXLDecoder.cpp

Lines changed: 6 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,20 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
66

77
#include "ImageLogging.h" // Must appear first
8-
#include "gfxPlatform.h"
9-
#include "jxl/codestream_header.h"
10-
#include "jxl/decode_cxx.h"
11-
#include "jxl/types.h"
12-
#include "mozilla/TelemetryHistogramEnums.h"
13-
#include "mozilla/gfx/Point.h"
8+
149
#include "nsJXLDecoder.h"
1510

1611
#include "RasterImage.h"
17-
#include "SurfacePipeFactory.h"
18-
19-
using namespace mozilla::gfx;
2012

2113
namespace mozilla::image {
2214

23-
#define JXL_TRY(expr) \
24-
do { \
25-
JxlDecoderStatus _status = (expr); \
26-
if (_status != JXL_DEC_SUCCESS) { \
27-
return Transition::TerminateFailure(); \
28-
} \
29-
} while (0);
30-
31-
#define JXL_TRY_BOOL(expr) \
32-
do { \
33-
bool succeeded = (expr); \
34-
if (!succeeded) { \
35-
return Transition::TerminateFailure(); \
36-
} \
37-
} while (0);
38-
3915
static LazyLogModule sJXLLog("JXLDecoder");
4016

4117
nsJXLDecoder::nsJXLDecoder(RasterImage* aImage)
4218
: Decoder(aImage),
4319
mLexer(Transition::ToUnbuffered(State::FINISHED_JXL_DATA, State::JXL_DATA,
4420
SIZE_MAX),
45-
Transition::TerminateSuccess()),
46-
mDecoder(JxlDecoderMake(nullptr)),
47-
mParallelRunner(
48-
JxlThreadParallelRunnerMake(nullptr, PreferredThreadCount())) {
49-
JxlDecoderSubscribeEvents(mDecoder.get(),
50-
JXL_DEC_BASIC_INFO | JXL_DEC_FULL_IMAGE);
51-
JxlDecoderSetParallelRunner(mDecoder.get(), JxlThreadParallelRunner,
52-
mParallelRunner.get());
53-
21+
Transition::TerminateSuccess()) {
5422
MOZ_LOG(sJXLLog, LogLevel::Debug,
5523
("[this=%p] nsJXLDecoder::nsJXLDecoder", this));
5624
}
@@ -60,20 +28,12 @@ nsJXLDecoder::~nsJXLDecoder() {
6028
("[this=%p] nsJXLDecoder::~nsJXLDecoder", this));
6129
}
6230

63-
size_t nsJXLDecoder::PreferredThreadCount() {
64-
if (IsMetadataDecode()) {
65-
return 0; // no additional worker thread
66-
}
67-
return JxlThreadParallelRunnerDefaultNumWorkerThreads();
68-
}
69-
7031
LexerResult nsJXLDecoder::DoDecode(SourceBufferIterator& aIterator,
7132
IResumable* aOnResume) {
72-
// return LexerResult(TerminalState::FAILURE);
7333
MOZ_ASSERT(!HasError(), "Shouldn't call DoDecode after error!");
7434

7535
return mLexer.Lex(aIterator, aOnResume,
76-
[=](State aState, const char* aData, size_t aLength) {
36+
[this](State aState, const char* aData, size_t aLength) {
7737
switch (aState) {
7838
case State::JXL_DATA:
7939
return ReadJXLData(aData, aLength);
@@ -82,80 +42,12 @@ LexerResult nsJXLDecoder::DoDecode(SourceBufferIterator& aIterator,
8242
}
8343
MOZ_CRASH("Unknown State");
8444
});
85-
};
45+
}
8646

8747
LexerTransition<nsJXLDecoder::State> nsJXLDecoder::ReadJXLData(
8848
const char* aData, size_t aLength) {
89-
const uint8_t* input = (const uint8_t*)aData;
90-
size_t length = aLength;
91-
if (mBuffer.length() != 0) {
92-
JXL_TRY_BOOL(mBuffer.append(aData, aLength));
93-
input = mBuffer.begin();
94-
length = mBuffer.length();
95-
}
96-
JXL_TRY(JxlDecoderSetInput(mDecoder.get(), input, length));
97-
98-
while (true) {
99-
JxlDecoderStatus status = JxlDecoderProcessInput(mDecoder.get());
100-
switch (status) {
101-
case JXL_DEC_ERROR:
102-
default:
103-
return Transition::TerminateFailure();
104-
105-
case JXL_DEC_NEED_MORE_INPUT: {
106-
size_t remaining = JxlDecoderReleaseInput(mDecoder.get());
107-
mBuffer.clear();
108-
JXL_TRY_BOOL(mBuffer.append(aData + aLength - remaining, remaining));
109-
return Transition::ContinueUnbuffered(State::JXL_DATA);
110-
}
111-
112-
case JXL_DEC_BASIC_INFO: {
113-
JXL_TRY(JxlDecoderGetBasicInfo(mDecoder.get(), &mInfo));
114-
PostSize(mInfo.xsize, mInfo.ysize);
115-
if (WantsFrameCount()) {
116-
PostFrameCount(/* aFrameCount */ 1);
117-
}
118-
if (mInfo.alpha_bits > 0) {
119-
PostHasTransparency();
120-
}
121-
if (IsMetadataDecode()) {
122-
return Transition::TerminateSuccess();
123-
}
124-
break;
125-
}
126-
127-
case JXL_DEC_NEED_IMAGE_OUT_BUFFER: {
128-
size_t size = 0;
129-
JxlPixelFormat format{4, JXL_TYPE_UINT8, JXL_LITTLE_ENDIAN, 0};
130-
JXL_TRY(JxlDecoderImageOutBufferSize(mDecoder.get(), &format, &size));
131-
132-
mOutBuffer.clear();
133-
JXL_TRY_BOOL(mOutBuffer.growBy(size));
134-
JXL_TRY(JxlDecoderSetImageOutBuffer(mDecoder.get(), &format,
135-
mOutBuffer.begin(), size));
136-
break;
137-
}
138-
139-
case JXL_DEC_FULL_IMAGE: {
140-
OrientedIntSize size(mInfo.xsize, mInfo.ysize);
141-
Maybe<SurfacePipe> pipe = SurfacePipeFactory::CreateSurfacePipe(
142-
this, size, OutputSize(), FullFrame(), SurfaceFormat::R8G8B8A8,
143-
SurfaceFormat::OS_RGBA, Nothing(), nullptr, SurfacePipeFlags());
144-
for (uint8_t* rowPtr = mOutBuffer.begin(); rowPtr < mOutBuffer.end();
145-
rowPtr += mInfo.xsize * 4) {
146-
pipe->WriteBuffer(reinterpret_cast<uint32_t*>(rowPtr));
147-
}
148-
149-
if (Maybe<SurfaceInvalidRect> invalidRect = pipe->TakeInvalidRect()) {
150-
PostInvalidation(invalidRect->mInputSpaceRect,
151-
Some(invalidRect->mOutputSpaceRect));
152-
}
153-
PostFrameStop();
154-
PostDecodeDone();
155-
return Transition::TerminateSuccess();
156-
}
157-
}
158-
}
49+
// Stub: JXL decoder removed, waiting for Rust replacement
50+
return Transition::TerminateFailure();
15951
}
16052

16153
LexerTransition<nsJXLDecoder::State> nsJXLDecoder::FinishedJXLData() {

image/decoders/nsJXLDecoder.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,14 @@
88
#define mozilla_image_decoders_nsJXLDecoder_h
99

1010
#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"
11+
#include "StreamingLexer.h"
1612

1713
namespace mozilla::image {
1814
class RasterImage;
1915

2016
class nsJXLDecoder final : public Decoder {
2117
public:
22-
virtual ~nsJXLDecoder();
18+
~nsJXLDecoder() override;
2319

2420
DecoderType GetType() const override { return DecoderType::JXL; }
2521

@@ -30,22 +26,14 @@ class nsJXLDecoder final : public Decoder {
3026
private:
3127
friend class DecoderFactory;
3228

33-
// Decoders should only be instantiated via DecoderFactory.
3429
explicit nsJXLDecoder(RasterImage* aImage);
3530

36-
size_t PreferredThreadCount();
37-
3831
enum class State { JXL_DATA, FINISHED_JXL_DATA };
3932

4033
LexerTransition<State> ReadJXLData(const char* aData, size_t aLength);
4134
LexerTransition<State> FinishedJXLData();
4235

4336
StreamingLexer<State> mLexer;
44-
JxlDecoderPtr mDecoder;
45-
JxlThreadParallelRunnerPtr mParallelRunner;
46-
Vector<uint8_t> mBuffer;
47-
Vector<uint8_t> mOutBuffer;
48-
JxlBasicInfo mInfo{};
4937
};
5038

5139
} // namespace mozilla::image

media/highway/moz.build

Lines changed: 0 additions & 62 deletions
This file was deleted.

media/highway/moz.yaml

Lines changed: 0 additions & 56 deletions
This file was deleted.

media/highway/mozilla.patch

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)