Add downscale-during-decode support for the GIF decoder

RESOLVED FIXED in Firefox 43

Status

()

defect
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: seth, Assigned: seth)

Tracking

(Blocks 1 bug)

unspecified
mozilla43
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox43 fixed)

Details

(Whiteboard: [gfx-noted])

Attachments

(2 attachments)

No description provided.
Depends on: 1194059
Whiteboard: [gfx-noted]
This is a preliminary patch that adds a helper class, Deinterlacer, which
buffers decoded rows of an image until an interlacing pass is over and can then
send them to a Downscaler for downscaling.

Obviously this boils down to buffering an un-downscaled copy of the image. This
means that for interlaced images that use Deinterlacer, DDD doesn't offer any
memory savings during decoding, but the Downscaler can be discarded afterwards,
so memory savings will continue as usual once the decode is complete.

Something similar to this is somewhat inevitable when interlacing is involved.
Conveniently, libpng does this for us internally, but since we implemented the
GIF decoder ourselves, we have to add buffering manually using Deinterlacer.
Attachment #8662246 - Flags: review?(tnikkel)
Assignee: nobody → seth
Status: NEW → ASSIGNED
This patch adds DDD support for the GIF decoder. The approach is very simple to
the one used for the PNG decoder.

The new wrinkles are:

 - GIFs can have first frame padding, which means we need to compute a scaled
   version of the frame rect when allocating a frame.

 - GIFs can have interlacing, and we don't currently do any extra buffering to
   perform deinterlacing. Part 1 added Deinterlacer, which serves as that extra
   buffer. If we determine that the GIF is interlaced, we create a Deinterlacer
   and write rows into it until an interlaced pass is complete. Then we use
   Deinterlacer::PropagatePassToDownscaler() to downscale all the rows from that
   pass at once.

All of this means that when we want to write a decoded row of the image into a
buffer, there are now three possible destinations: mImageData, if we're not
downscaling; our Downscaler's buffer, if we're downscaling but not
deinterlacing; and our Deinterlacer's buffer, if we're downscaling *and*
deinterlacing. GetCurrentRowBuffer() hides this complexity from most of the GIF
decoder code.
Attachment #8662251 - Flags: review?(tnikkel)
(Woot, after this lands all the decoders will support DDD!)
Attachment #8662246 - Flags: review?(tnikkel) → review+
Attachment #8662251 - Flags: review?(tnikkel) → review+
Thanks for the review!
https://hg.mozilla.org/mozilla-central/rev/5fefb6834270
https://hg.mozilla.org/mozilla-central/rev/3c9f7ca5a12f
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla43
Depends on: 1207378
Depends on: 1208764
Depends on: 1208935
Depends on: 1213744
Depends on: 1231121
Depends on: 1229825
Depends on: 1235605
You need to log in before you can comment on or make changes to this bug.