Skip to content

Commit 5b0ee75

Browse files
author
Sandor Molnar
committed
Backed out 2 changesets (bug 1901076) for causing assertion failures @ image/RasterImage.cpp CLOSED TREE
Backed out changeset de52938146cd (bug 1901076) Backed out changeset 79fece25d231 (bug 1901076)
1 parent 3cdcab4 commit 5b0ee75

23 files changed

+78
-403
lines changed

dom/media/mp4/SampleIterator.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,29 +80,6 @@ SampleIterator::~SampleIterator() { mIndex->UnregisterIterator(this); }
8080

8181
bool SampleIterator::HasNext() { return !!Get(); }
8282

83-
already_AddRefed<MediaRawData> SampleIterator::GetNextHeader() {
84-
Sample* s(Get());
85-
if (!s) {
86-
return nullptr;
87-
}
88-
89-
int64_t length = std::numeric_limits<int64_t>::max();
90-
mIndex->mSource->Length(&length);
91-
if (s->mByteRange.mEnd > length) {
92-
// We don't have this complete sample.
93-
return nullptr;
94-
}
95-
96-
RefPtr<MediaRawData> sample = new MediaRawData();
97-
sample->mTimecode = s->mDecodeTime;
98-
sample->mTime = s->mCompositionRange.start;
99-
sample->mDuration = s->mCompositionRange.Length();
100-
sample->mOffset = s->mByteRange.mStart;
101-
sample->mKeyframe = s->mSync;
102-
Next();
103-
return sample.forget();
104-
}
105-
10683
already_AddRefed<MediaRawData> SampleIterator::GetNext() {
10784
Sample* s(Get());
10885
if (!s) {

dom/media/mp4/SampleIterator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class SampleIterator {
2626
explicit SampleIterator(MP4SampleIndex* aIndex);
2727
~SampleIterator();
2828
bool HasNext();
29-
already_AddRefed<mozilla::MediaRawData> GetNextHeader();
3029
already_AddRefed<mozilla::MediaRawData> GetNext();
3130
void Seek(const media::TimeUnit& aTime);
3231
media::TimeUnit GetNextKeyframeTime();

image/Decoder.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ nsresult Decoder::Init() {
151151
// XXX(seth): Soon that exception will be removed.
152152
MOZ_ASSERT_IF(mImage, IsMetadataDecode());
153153

154-
// We can only request the frame count for metadata decoders.
155-
MOZ_ASSERT_IF(WantsFrameCount(), IsMetadataDecode());
156-
157154
// Implementation-specific initialization.
158155
nsresult rv = InitInternal();
159156

@@ -470,10 +467,6 @@ void Decoder::PostIsAnimated(FrameTimeout aFirstFrameTimeout) {
470467
mImageMetadata.SetFirstFrameTimeout(aFirstFrameTimeout);
471468
}
472469

473-
void Decoder::PostFrameCount(uint32_t aFrameCount) {
474-
mImageMetadata.SetFrameCount(aFrameCount);
475-
}
476-
477470
void Decoder::PostFrameStop(Opacity aFrameOpacity) {
478471
// We should be mid-frame
479472
MOZ_ASSERT(!IsMetadataDecode(), "Stopping frame during metadata decode");
@@ -540,16 +533,14 @@ void Decoder::PostInvalidation(const OrientedIntRect& aRect,
540533
}
541534
}
542535

543-
void Decoder::PostLoopCount(int32_t aLoopCount) {
544-
mImageMetadata.SetLoopCount(aLoopCount);
545-
}
546-
547-
void Decoder::PostDecodeDone() {
536+
void Decoder::PostDecodeDone(int32_t aLoopCount /* = 0 */) {
548537
MOZ_ASSERT(!IsMetadataDecode(), "Done with decoding in metadata decode");
549538
MOZ_ASSERT(!mInFrame, "Can't be done decoding if we're mid-frame!");
550539
MOZ_ASSERT(!mDecodeDone, "Decode already done!");
551540
mDecodeDone = true;
552541

542+
mImageMetadata.SetLoopCount(aLoopCount);
543+
553544
// Some metadata that we track should take into account every frame in the
554545
// image. If this is a first-frame-only decode, our accumulated loop length
555546
// and first frame refresh area only includes the first frame, so it's not

image/Decoder.h

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,6 @@ class Decoder {
197197
}
198198
bool IsMetadataDecode() const { return mMetadataDecode; }
199199

200-
/**
201-
* Should we return how many frames we expect are in the animation.
202-
*/
203-
bool WantsFrameCount() const {
204-
return bool(mDecoderFlags & DecoderFlags::COUNT_FRAMES);
205-
}
206-
207200
/**
208201
* Sets the output size of this decoder. If this is smaller than the intrinsic
209202
* size of the image, we'll downscale it while decoding. For memory usage
@@ -307,7 +300,7 @@ class Decoder {
307300
/// useless?
308301
bool GetDecodeDone() const {
309302
return mReachedTerminalState || mDecodeDone ||
310-
(mMetadataDecode && HasSize() && !WantsFrameCount()) || HasError();
303+
(mMetadataDecode && HasSize()) || HasError();
311304
}
312305

313306
/// Are we in the middle of a frame right now? Used for assertions only.
@@ -512,10 +505,6 @@ class Decoder {
512505
// we advance to the next frame.
513506
void PostIsAnimated(FrameTimeout aFirstFrameTimeout);
514507

515-
// Called by decoders if they determine the expected frame count.
516-
// @param aFrameCount The expected frame count.
517-
void PostFrameCount(uint32_t aFrameCount);
518-
519508
// Called by decoders when they end a frame. Informs the image, sends
520509
// notifications, and does internal book-keeping.
521510
// Specify whether this frame is opaque as an optimization.
@@ -538,16 +527,15 @@ class Decoder {
538527
const OrientedIntRect& aRect,
539528
const Maybe<OrientedIntRect>& aRectAtOutputSize = Nothing());
540529

541-
// For animated images, specify the loop count. -1 means loop forever, 0
542-
// means a single iteration, stopping on the last frame.
543-
void PostLoopCount(int32_t aLoopCount);
544-
545530
// Called by the decoders when they have successfully decoded the image. This
546531
// may occur as the result of the decoder getting to the appropriate point in
547532
// the stream, or by us calling FinishInternal().
548533
//
549534
// May not be called mid-frame.
550-
void PostDecodeDone();
535+
//
536+
// For animated images, specify the loop count. -1 means loop forever, 0
537+
// means a single iteration, stopping on the last frame.
538+
void PostDecodeDone(int32_t aLoopCount = 0);
551539

552540
/**
553541
* Allocates a new frame, making it our current frame if successful.

image/DecoderFactory.cpp

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ nsresult DecoderFactory::CreateDecoder(
178178
return NS_ERROR_INVALID_ARG;
179179
}
180180

181-
// Only can use COUNT_FRAMES with metadata decoders.
182-
if (NS_WARN_IF(bool(aDecoderFlags & DecoderFlags::COUNT_FRAMES))) {
183-
return NS_ERROR_INVALID_ARG;
184-
}
185-
186181
// Create an anonymous decoder. Interaction with the SurfaceCache and the
187182
// owning RasterImage will be mediated by DecodedSurfaceProvider.
188183
RefPtr<Decoder> decoder = GetDecoder(
@@ -238,11 +233,6 @@ nsresult DecoderFactory::CreateAnimationDecoder(
238233
return NS_ERROR_INVALID_ARG;
239234
}
240235

241-
// Only can use COUNT_FRAMES with metadata decoders.
242-
if (NS_WARN_IF(bool(aDecoderFlags & DecoderFlags::COUNT_FRAMES))) {
243-
return NS_ERROR_INVALID_ARG;
244-
}
245-
246236
MOZ_ASSERT(aType == DecoderType::GIF || aType == DecoderType::PNG ||
247237
aType == DecoderType::WEBP || aType == DecoderType::AVIF,
248238
"Calling CreateAnimationDecoder for non-animating DecoderType");
@@ -401,11 +391,6 @@ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousDecoder(
401391
return nullptr;
402392
}
403393

404-
// Only can use COUNT_FRAMES with metadata decoders.
405-
if (NS_WARN_IF(bool(aDecoderFlags & DecoderFlags::COUNT_FRAMES))) {
406-
return nullptr;
407-
}
408-
409394
RefPtr<Decoder> decoder =
410395
GetDecoder(aType, /* aImage = */ nullptr, /* aIsRedecode = */ false);
411396
MOZ_ASSERT(decoder, "Should have a decoder now");
@@ -435,8 +420,7 @@ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousDecoder(
435420

436421
/* static */
437422
already_AddRefed<Decoder> DecoderFactory::CreateAnonymousMetadataDecoder(
438-
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer,
439-
DecoderFlags aDecoderFlags) {
423+
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer) {
440424
if (aType == DecoderType::UNKNOWN) {
441425
return nullptr;
442426
}
@@ -448,7 +432,7 @@ already_AddRefed<Decoder> DecoderFactory::CreateAnonymousMetadataDecoder(
448432
// Initialize the decoder.
449433
decoder->SetMetadataDecode(true);
450434
decoder->SetIterator(aSourceBuffer->Iterator());
451-
decoder->SetDecoderFlags(aDecoderFlags);
435+
decoder->SetDecoderFlags(DecoderFlags::FIRST_FRAME_ONLY);
452436

453437
if (NS_FAILED(decoder->Init())) {
454438
return nullptr;

image/DecoderFactory.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,9 @@ class DecoderFactory {
190190
* @param aType Which type of decoder to create - JPEG, PNG, etc.
191191
* @param aSourceBuffer The SourceBuffer which the decoder will read its data
192192
* from.
193-
* @param aDecoderFlags Flags specifying the behavior of this decoder.
194193
*/
195194
static already_AddRefed<Decoder> CreateAnonymousMetadataDecoder(
196-
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer,
197-
DecoderFlags aDecoderFlags);
195+
DecoderType aType, NotNull<SourceBuffer*> aSourceBuffer);
198196

199197
private:
200198
virtual ~DecoderFactory() = 0;

image/DecoderFlags.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ enum class DecoderFlags : uint8_t {
4242
// "image.avif.sequence.animate_avif_major_branded_images" preference.
4343
AVIF_ANIMATE_AVIF_MAJOR = 1 << 6,
4444
#endif
45-
46-
/**
47-
* By default, we don't count how many animated frames there are in an image,
48-
* as that would require us to iterate over the entire buffer for some image
49-
* formats. If the caller requires a full accounting of how many frames there
50-
* are.
51-
*/
52-
COUNT_FRAMES = 1 << 7,
5345
};
5446
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(DecoderFlags)
5547

image/ImageMetadata.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ class ImageMetadata {
3838
FrameTimeout GetLoopLength() const { return *mLoopLength; }
3939
bool HasLoopLength() const { return mLoopLength.isSome(); }
4040

41-
void SetFrameCount(uint32_t aCount) { mFrameCount = Some(aCount); }
42-
uint32_t GetFrameCount() const { return *mFrameCount; }
43-
bool HasFrameCount() const { return mFrameCount.isSome(); }
44-
4541
void SetFirstFrameTimeout(FrameTimeout aTimeout) {
4642
mFirstFrameTimeout = aTimeout;
4743
}
@@ -98,9 +94,6 @@ class ImageMetadata {
9894
// The total length of a single loop through an animated image.
9995
Maybe<FrameTimeout> mLoopLength;
10096

101-
// The total number of frames we expect from the animated image.
102-
Maybe<uint32_t> mFrameCount;
103-
10497
/// The timeout of an animated image's first frame.
10598
FrameTimeout mFirstFrameTimeout = FrameTimeout::Forever();
10699

image/ImageOps.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,8 @@ nsresult ImageOps::DecodeMetadata(ImageBuffer* aBuffer,
171171
// Create a decoder.
172172
DecoderType decoderType =
173173
DecoderFactory::GetDecoderType(PromiseFlatCString(aMimeType).get());
174-
DecoderFlags decoderFlags =
175-
DecoderFactory::GetDefaultDecoderFlagsForType(decoderType);
176-
decoderFlags |= DecoderFlags::FIRST_FRAME_ONLY;
177174
RefPtr<Decoder> decoder = DecoderFactory::CreateAnonymousMetadataDecoder(
178-
decoderType, WrapNotNull(sourceBuffer), decoderFlags);
175+
decoderType, WrapNotNull(sourceBuffer));
179176
if (!decoder) {
180177
return NS_ERROR_FAILURE;
181178
}

image/RasterImage.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -702,9 +702,6 @@ bool RasterImage::SetMetadata(const ImageMetadata& aMetadata,
702702
StoreHasSize(true);
703703
}
704704

705-
MOZ_ASSERT_IF(mAnimationState && !aFromMetadataDecode,
706-
mAnimationState->LoopCount() == aMetadata.GetLoopCount());
707-
708705
if (LoadHasSize() && aMetadata.HasAnimation() && !mAnimationState) {
709706
// We're becoming animated, so initialize animation stuff.
710707
mAnimationState.emplace(mAnimationMode);

0 commit comments

Comments
 (0)