SkGainmapEncoder: Add MP extensions to all individual images

In CIPA DC-007, it is not completely clear if it is required that
all images (the base image and the gainmap image) must include MP
extensions (the APP2 marker with MPF metadata).

It is also likely that we will need to include MP extensions if CIPA
DC-007 is updated to include gainmap support.

To be on the safe side, make SkJpegGainmapEncoder::MakeMPF add MP
extensions to all individual images, not just the first one.

To SkJpegMultiPictureParameters::serialize, add an individual
image number parameter, and conditionalize which parts are written
based on that (in particular only write the version for non-first
individual images).

Make SkJpegGainmapEncoder::MakeMPF add the MPF segment to all images.

Then add a bunch of tests.

Bug: b/338342146
Change-Id: I1f7fc59313fec478a243fddbbe6a6a02a104fb8d
Commit-Queue: Christopher Cameron <>
Reviewed-by: Brian Osman <>
Reviewed-by: Christopher Cameron <>
4 files changed