File: SkJpegMetadataDecoder.h

package info (click to toggle)
webkit2gtk 2.51.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 455,340 kB
  • sloc: cpp: 3,865,253; javascript: 197,710; ansic: 165,177; python: 49,241; asm: 21,868; ruby: 18,095; perl: 16,926; xml: 4,623; sh: 2,409; yacc: 2,356; java: 2,019; lex: 1,330; pascal: 372; makefile: 210
file content (98 lines) | stat: -rw-r--r-- 3,458 bytes parent folder | download | duplicates (22)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * Copyright 2013 Google Inc.
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkJpegMetadataDecoder_DEFINED
#define SkJpegMetadataDecoder_DEFINED

#include "include/core/SkData.h"
#include "include/core/SkRefCnt.h"
#include "include/core/SkTypes.h"

#include <memory>
#include <vector>

struct SkGainmapInfo;

/**
 * An interface that can be used to extract metadata from an encoded JPEG file.
 */
class SK_API SkJpegMetadataDecoder {
public:
    SkJpegMetadataDecoder() {}
    virtual ~SkJpegMetadataDecoder() {}

    SkJpegMetadataDecoder(const SkJpegMetadataDecoder&) = delete;
    SkJpegMetadataDecoder& operator=(const SkJpegMetadataDecoder&) = delete;

    /**
     * A segment from a JPEG file. This is usually populated from a jpeg_marker_struct.
     */
    struct SK_API Segment {
        Segment(uint8_t marker, sk_sp<SkData> data) : fMarker(marker), fData(std::move(data)) {}

        // The segment's marker.
        uint8_t fMarker = 0;

        // The segment's parameters (not including the marker and parameter length).
        sk_sp<SkData> fData;
    };

    /**
     * Create metadata for the specified segments from a JPEG file's header (defined as all segments
     * before the first StartOfScan). This may return nullptr.
     */
    static std::unique_ptr<SkJpegMetadataDecoder> Make(std::vector<Segment> headerSegments);

    /**
     * Create metadata for the specified encoded JPEG file. This may return nullptr.
     */
    static std::unique_ptr<SkJpegMetadataDecoder> Make(sk_sp<SkData> data);

    /**
     * Return the Exif data attached to the image (if any) and nullptr otherwise. If |copyData| is
     * false, then the returned SkData may directly reference the data provided when this object was
     * created.
     */
    virtual sk_sp<SkData> getExifMetadata(bool copyData) const = 0;

    /**
     * Return the ICC profile of the image if any, and nullptr otherwise. If |copyData| is false,
     * then the returned SkData may directly reference the data provided when this object was
     * created.
     */
    virtual sk_sp<SkData> getICCProfileData(bool copyData) const = 0;

    /**
     * Return the ISO 21496-1 metadata, if any, and nullptr otherwise. If |copyData| is false,
     * then the returned SkData may directly reference the data provided when this object was
     * created.
     */
    virtual sk_sp<SkData> getISOGainmapMetadata(bool copyData) const = 0;

    /**
     * Return true if there is a possibility that this image contains a gainmap image.
     */
    virtual bool mightHaveGainmapImage() const = 0;

    /**
     * Given a JPEG encoded image |baseImageData|, return in |outGainmapImageData| the JPEG encoded
     * gainmap image and return in |outGainmapInfo| its gainmap rendering parameters. Return true if
     * both output variables were successfully populated, otherwise return false.
     */
    virtual bool findGainmapImage(sk_sp<SkData> baseImageData,
                                  sk_sp<SkData>& outGainmapImagedata,
                                  SkGainmapInfo& outGainmapInfo) = 0;

     /**
      * Return the first JUMBF superbox, if any, and nullptr otherwise. If |copyData| is false,
      * then the returned SkData may directly reference the data provided when this object was
      * created.
      */
    virtual sk_sp<SkData> getJUMBFMetadata(bool copyData) const = 0;
};

#endif