Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkJpegMultiPicture.h
Go to the documentation of this file.
1/*
2 * Copyright 2023 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkJpegMultiPicture_codec_DEFINED
9#define SkJpegMultiPicture_codec_DEFINED
10
12
13#include <cstdint>
14#include <memory>
15#include <vector>
16
17class SkData;
18
19/*
20 * Parsed Jpeg Multi-Picture Format structure as specified in CIPA DC-x007-2009. An introduction to
21 * the format can be found in Figure 1 (Basic MP File format data structure) and Figure 6 (Internal
22 * Structure of the MP Index IFD) in that document. This parsing will extract only the size and
23 * offset parameters from the images in the Index Image File Directory.
24 */
26 // An individual image.
27 struct Image {
28 // The size of the image in bytes.
29 uint32_t size = 0;
30 // The offset of the image in bytes. This offset is specified relative to the address of
31 // the MP Endian field in the MP Header, unless the image is a First Individual Image, in
32 // which case the value of the offest [sic] shall be NULL (from section 5.2.3.3).
33 uint32_t dataOffset = 0;
34 };
35
36 // The images listed in the Index Image File Directory.
37 std::vector<Image> images;
38
39 /*
40 * Parse Jpeg Multi-Picture Format parameters. The specified data should be APP2 segment
41 * parameters, which, if they are MPF parameter, should start with the {'M', 'P', 'F', 0}
42 * signature. Returns nullptr the parameters do not start with the MPF signature, or if there
43 * is an error in parsing the parameters.
44 */
45 static std::unique_ptr<SkJpegMultiPictureParameters> Make(
46 const sk_sp<const SkData>& segmentParameters);
47
48 /*
49 * Serialize Jpeg Multi-Picture Format parameters into a segment. This segment will start with
50 * the {'M', 'P', 'F', 0} signature (it will not include the segment marker or parameter
51 * length).
52 */
54
55 /*
56 * Compute the absolute offset (from the start of the image) for the offset in the multi-picture
57 * parameters, given the absolute offset of the MPF segment (the offset of the {0xFF, 0xE2}
58 * marker from the start of the image.
59 */
60 static size_t GetAbsoluteOffset(uint32_t dataOffset, size_t mpSegmentOffset);
61};
62
63#endif
sk_sp< SkData > serialize() const
static size_t GetAbsoluteOffset(uint32_t dataOffset, size_t mpSegmentOffset)
static std::unique_ptr< SkJpegMultiPictureParameters > Make(const sk_sp< const SkData > &segmentParameters)