blob: 413ec6280034af9a332edcf3154c5379433d4c4f [file] [log] [blame]
Mike Klein36f182f2017-10-20 12:33:53 -04001/*
2 * Copyright 2017 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 SkStubHeifDecoderAPI_DEFINED
9#define SkStubHeifDecoderAPI_DEFINED
10
11// This stub implementation of HeifDecoderAPI.h lets us compile SkHeifCodec.cpp
12// even when libheif is not available. It, of course, does nothing and fails to decode.
13
14#include <memory>
15#include <stddef.h>
16#include <stdint.h>
Mike Klein36f182f2017-10-20 12:33:53 -040017
18enum HeifColorFormat {
19 kHeifColorFormat_RGB565,
20 kHeifColorFormat_RGBA_8888,
21 kHeifColorFormat_BGRA_8888,
22};
23
24struct HeifStream {
25 virtual ~HeifStream() {}
26
27 virtual size_t read(void*, size_t) = 0;
28 virtual bool rewind() = 0;
29 virtual bool seek(size_t) = 0;
30 virtual bool hasLength() const = 0;
31 virtual size_t getLength() const = 0;
32};
33
34struct HeifFrameInfo {
Leon Scroggins III6154ac42019-08-14 11:29:29 -040035 uint32_t mWidth;
36 uint32_t mHeight;
37 int32_t mRotationAngle; // Rotation angle, clockwise, should be multiple of 90
38 uint32_t mBytesPerPixel; // Number of bytes for one pixel
39 int64_t mDurationUs; // Duration of the frame in us
40 std::vector<uint8_t> mIccData; // ICC data array
Mike Klein36f182f2017-10-20 12:33:53 -040041};
42
43struct HeifDecoder {
44 bool init(HeifStream* stream, HeifFrameInfo*) {
45 delete stream;
46 return false;
47 }
48
Leon Scroggins III6154ac42019-08-14 11:29:29 -040049 bool getSequenceInfo(HeifFrameInfo* frameInfo, size_t *frameCount) {
50 return false;
51 }
Leon Scroggins III6154ac42019-08-14 11:29:29 -040052
Mike Klein36f182f2017-10-20 12:33:53 -040053 bool decode(HeifFrameInfo*) {
54 return false;
55 }
56
Leon Scroggins III6154ac42019-08-14 11:29:29 -040057 bool decodeSequence(int frameIndex, HeifFrameInfo* frameInfo) {
58 return false;
59 }
Leon Scroggins III6154ac42019-08-14 11:29:29 -040060
Mike Klein36f182f2017-10-20 12:33:53 -040061 bool setOutputColor(HeifColorFormat) {
62 return false;
63 }
64
65 bool getScanline(uint8_t*) {
66 return false;
67 }
68
69 int skipScanlines(int) {
70 return 0;
71 }
72};
73
74static inline HeifDecoder* createHeifDecoder() { return new HeifDecoder; }
75
76#endif//SkStubHeifDecoderAPI_DEFINED