blob: 201cd74bfd49da23485cf844db4315c377fe5d92 [file] [log] [blame]
scroggof24f2242015-03-03 08:59:20 -08001/*
2 * Copyright 2015 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 SkCodec_DEFINED
9#define SkCodec_DEFINED
10
Ben Wagnerd5148e32018-07-16 17:44:06 -040011#include "../private/SkNoncopyable.h"
bungemanf3c15b72015-08-19 11:56:48 -070012#include "../private/SkTemplates.h"
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -050013#include "../private/SkEncodedInfo.h"
Leon Scroggins III33deb7e2017-06-07 12:31:51 -040014#include "SkCodecAnimation.h"
scroggoeb602a52015-07-09 08:16:03 -070015#include "SkColor.h"
Hal Canarydb683012016-11-23 08:55:18 -070016#include "SkEncodedImageFormat.h"
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -040017#include "SkEncodedOrigin.h"
scroggof24f2242015-03-03 08:59:20 -080018#include "SkImageInfo.h"
Mike Reed43798692017-10-17 18:04:32 +000019#include "SkPixmap.h"
scroggof24f2242015-03-03 08:59:20 -080020#include "SkSize.h"
scroggofffeede2015-03-18 10:50:37 -070021#include "SkStream.h"
scroggof24f2242015-03-03 08:59:20 -080022#include "SkTypes.h"
Jim Van Verthe24b5872018-10-29 16:26:02 -040023#include "SkYUVASizeInfo.h"
scroggof24f2242015-03-03 08:59:20 -080024
scroggo19b91532016-10-24 09:03:26 -070025#include <vector>
26
msarettad8bcfe2016-03-07 07:09:03 -080027class SkColorSpace;
scroggof24f2242015-03-03 08:59:20 -080028class SkData;
Leon Scroggins III1f6af6b2017-06-12 16:41:09 -040029class SkFrameHolder;
scroggocf98fa92015-11-23 08:14:40 -080030class SkPngChunkReader;
scroggoe7fc14b2015-10-02 13:14:46 -070031class SkSampler;
scroggof24f2242015-03-03 08:59:20 -080032
msarett9876ac52016-06-01 14:47:18 -070033namespace DM {
scroggo8e6c7ad2016-09-16 08:20:38 -070034class CodecSrc;
msarett9876ac52016-06-01 14:47:18 -070035class ColorCodecSrc;
36}
37
scroggof24f2242015-03-03 08:59:20 -080038/**
39 * Abstraction layer directly on top of an image codec.
40 */
Florin Malita78c212a2016-12-14 13:17:01 -050041class SK_API SkCodec : SkNoncopyable {
scroggof24f2242015-03-03 08:59:20 -080042public:
43 /**
scroggodb30be22015-12-08 18:54:13 -080044 * Minimum number of bytes that must be buffered in SkStream input.
45 *
46 * An SkStream passed to NewFromStream must be able to use this many
47 * bytes to determine the image type. Then the same SkStream must be
48 * passed to the correct decoder to read from the beginning.
49 *
50 * This can be accomplished by implementing peek() to support peeking
51 * this many bytes, or by implementing rewind() to be able to rewind()
52 * after reading this many bytes.
53 */
Leon Scroggins III04be2b52017-08-17 15:13:20 -040054 static constexpr size_t MinBufferedBytesNeeded() { return 32; }
scroggodb30be22015-12-08 18:54:13 -080055
56 /**
Leon Scroggins III588fb042017-07-14 16:32:31 -040057 * Error codes for various SkCodec methods.
58 */
59 enum Result {
60 /**
61 * General return value for success.
62 */
63 kSuccess,
64 /**
65 * The input is incomplete. A partial image was generated.
66 */
67 kIncompleteInput,
68 /**
69 * Like kIncompleteInput, except the input had an error.
70 *
71 * If returned from an incremental decode, decoding cannot continue,
72 * even with more data.
73 */
74 kErrorInInput,
75 /**
76 * The generator cannot convert to match the request, ignoring
77 * dimensions.
78 */
79 kInvalidConversion,
80 /**
81 * The generator cannot scale to requested size.
82 */
83 kInvalidScale,
84 /**
85 * Parameters (besides info) are invalid. e.g. NULL pixels, rowBytes
86 * too small, etc.
87 */
88 kInvalidParameters,
89 /**
90 * The input did not contain a valid image.
91 */
92 kInvalidInput,
93 /**
94 * Fulfilling this request requires rewinding the input, which is not
95 * supported for this input.
96 */
97 kCouldNotRewind,
98 /**
99 * An internal error, such as OOM.
100 */
101 kInternalError,
102 /**
103 * This method is not implemented by this codec.
104 * FIXME: Perhaps this should be kUnsupported?
105 */
106 kUnimplemented,
107 };
108
109 /**
Leon Scroggins IIIfe3da022018-01-16 11:56:54 -0500110 * Readable string representing the error code.
111 */
112 static const char* ResultToString(Result);
113
114 /**
scroggof24f2242015-03-03 08:59:20 -0800115 * If this stream represents an encoded image that we know how to decode,
116 * return an SkCodec that can decode it. Otherwise return NULL.
117 *
scroggodb30be22015-12-08 18:54:13 -0800118 * As stated above, this call must be able to peek or read
119 * MinBufferedBytesNeeded to determine the correct format, and then start
120 * reading from the beginning. First it will attempt to peek, and it
121 * assumes that if less than MinBufferedBytesNeeded bytes (but more than
122 * zero) are returned, this is because the stream is shorter than this,
123 * so falling back to reading would not provide more data. If peek()
124 * returns zero bytes, this call will instead attempt to read(). This
125 * will require that the stream can be rewind()ed.
126 *
Leon Scroggins III588fb042017-07-14 16:32:31 -0400127 * If Result is not NULL, it will be set to either kSuccess if an SkCodec
128 * is returned or a reason for the failure if NULL is returned.
129 *
scroggodb30be22015-12-08 18:54:13 -0800130 * If SkPngChunkReader is not NULL, take a ref and pass it to libpng if
131 * the image is a png.
132 *
msarett7d5105c2015-12-02 07:02:41 -0800133 * If the SkPngChunkReader is not NULL then:
134 * If the image is not a PNG, the SkPngChunkReader will be ignored.
135 * If the image is a PNG, the SkPngChunkReader will be reffed.
136 * If the PNG has unknown chunks, the SkPngChunkReader will be used
137 * to handle these chunks. SkPngChunkReader will be called to read
138 * any unknown chunk at any point during the creation of the codec
139 * or the decode. Note that if SkPngChunkReader fails to read a
140 * chunk, this could result in a failure to create the codec or a
141 * failure to decode the image.
142 * If the PNG does not contain unknown chunks, the SkPngChunkReader
143 * will not be used or modified.
scroggocf98fa92015-11-23 08:14:40 -0800144 *
scroggof24f2242015-03-03 08:59:20 -0800145 * If NULL is returned, the stream is deleted immediately. Otherwise, the
146 * SkCodec takes ownership of it, and will delete it when done with it.
147 */
Mike Reedede7bac2017-07-23 15:30:02 -0400148 static std::unique_ptr<SkCodec> MakeFromStream(std::unique_ptr<SkStream>, Result* = nullptr,
149 SkPngChunkReader* = nullptr);
scroggof24f2242015-03-03 08:59:20 -0800150
151 /**
152 * If this data represents an encoded image that we know how to decode,
153 * return an SkCodec that can decode it. Otherwise return NULL.
154 *
msarett7d5105c2015-12-02 07:02:41 -0800155 * If the SkPngChunkReader is not NULL then:
156 * If the image is not a PNG, the SkPngChunkReader will be ignored.
157 * If the image is a PNG, the SkPngChunkReader will be reffed.
158 * If the PNG has unknown chunks, the SkPngChunkReader will be used
159 * to handle these chunks. SkPngChunkReader will be called to read
160 * any unknown chunk at any point during the creation of the codec
161 * or the decode. Note that if SkPngChunkReader fails to read a
162 * chunk, this could result in a failure to create the codec or a
163 * failure to decode the image.
164 * If the PNG does not contain unknown chunks, the SkPngChunkReader
165 * will not be used or modified.
scroggof24f2242015-03-03 08:59:20 -0800166 */
Mike Reedede7bac2017-07-23 15:30:02 -0400167 static std::unique_ptr<SkCodec> MakeFromData(sk_sp<SkData>, SkPngChunkReader* = nullptr);
168
scroggoeb602a52015-07-09 08:16:03 -0700169 virtual ~SkCodec();
170
171 /**
Leon Scroggins III712476e2018-10-03 15:47:00 -0400172 * Return a reasonable SkImageInfo to decode into.
scroggoeb602a52015-07-09 08:16:03 -0700173 */
Leon Scroggins III712476e2018-10-03 15:47:00 -0400174 SkImageInfo getInfo() const { return fEncodedInfo.makeImageInfo(); }
175
176 SkISize dimensions() const { return {fEncodedInfo.width(), fEncodedInfo.height()}; }
177 SkIRect bounds() const {
178 return SkIRect::MakeWH(fEncodedInfo.width(), fEncodedInfo.height());
179 }
scroggoeb602a52015-07-09 08:16:03 -0700180
msarett0e6274f2016-03-21 08:04:40 -0700181 /**
182 * Returns the image orientation stored in the EXIF data.
183 * If there is no EXIF data, or if we cannot read the EXIF data, returns kTopLeft.
184 */
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400185 SkEncodedOrigin getOrigin() const { return fOrigin; }
msarett0e6274f2016-03-21 08:04:40 -0700186
msarett6a738212016-03-04 13:27:35 -0800187 /**
scroggof24f2242015-03-03 08:59:20 -0800188 * Return a size that approximately supports the desired scale factor.
189 * The codec may not be able to scale efficiently to the exact scale
190 * factor requested, so return a size that approximates that scale.
emmaleer8f4ba762015-08-14 07:44:46 -0700191 * The returned value is the codec's suggestion for the closest valid
192 * scale that it can natively support
scroggof24f2242015-03-03 08:59:20 -0800193 */
scroggofffeede2015-03-18 10:50:37 -0700194 SkISize getScaledDimensions(float desiredScale) const {
msarettb32758a2015-08-18 13:22:46 -0700195 // Negative and zero scales are errors.
196 SkASSERT(desiredScale > 0.0f);
197 if (desiredScale <= 0.0f) {
198 return SkISize::Make(0, 0);
199 }
200
201 // Upscaling is not supported. Return the original size if the client
202 // requests an upscale.
203 if (desiredScale >= 1.0f) {
Leon Scroggins III712476e2018-10-03 15:47:00 -0400204 return this->dimensions();
msarettb32758a2015-08-18 13:22:46 -0700205 }
scroggofffeede2015-03-18 10:50:37 -0700206 return this->onGetScaledDimensions(desiredScale);
207 }
scroggof24f2242015-03-03 08:59:20 -0800208
scroggo1dd3ea92015-03-20 11:55:55 -0700209 /**
scroggob636b452015-07-22 07:16:20 -0700210 * Return (via desiredSubset) a subset which can decoded from this codec,
211 * or false if this codec cannot decode subsets or anything similar to
212 * desiredSubset.
213 *
214 * @param desiredSubset In/out parameter. As input, a desired subset of
215 * the original bounds (as specified by getInfo). If true is returned,
216 * desiredSubset may have been modified to a subset which is
217 * supported. Although a particular change may have been made to
218 * desiredSubset to create something supported, it is possible other
219 * changes could result in a valid subset.
220 * If false is returned, desiredSubset's value is undefined.
221 * @return true if this codec supports decoding desiredSubset (as
222 * returned, potentially modified)
223 */
224 bool getValidSubset(SkIRect* desiredSubset) const {
225 return this->onGetValidSubset(desiredSubset);
226 }
227
228 /**
scroggo1dd3ea92015-03-20 11:55:55 -0700229 * Format of the encoded data.
230 */
Hal Canarydb683012016-11-23 08:55:18 -0700231 SkEncodedImageFormat getEncodedFormat() const { return this->onGetEncodedFormat(); }
scroggo1dd3ea92015-03-20 11:55:55 -0700232
scroggo05245902015-03-25 11:11:52 -0700233 /**
scroggoeb602a52015-07-09 08:16:03 -0700234 * Whether or not the memory passed to getPixels is zero initialized.
235 */
236 enum ZeroInitialized {
237 /**
238 * The memory passed to getPixels is zero initialized. The SkCodec
239 * may take advantage of this by skipping writing zeroes.
240 */
241 kYes_ZeroInitialized,
242 /**
243 * The memory passed to getPixels has not been initialized to zero,
244 * so the SkCodec must write all zeroes to memory.
245 *
246 * This is the default. It will be used if no Options struct is used.
247 */
248 kNo_ZeroInitialized,
249 };
250
251 /**
252 * Additional options to pass to getPixels.
253 */
254 struct Options {
255 Options()
scroggob636b452015-07-22 07:16:20 -0700256 : fZeroInitialized(kNo_ZeroInitialized)
scroggo19b91532016-10-24 09:03:26 -0700257 , fSubset(nullptr)
258 , fFrameIndex(0)
Nigel Tao66bc5242018-08-22 10:56:03 +1000259 , fPriorFrame(kNoFrame)
scroggob636b452015-07-22 07:16:20 -0700260 {}
scroggoeb602a52015-07-09 08:16:03 -0700261
Matt Sarettcf3f2342017-03-23 15:32:25 -0400262 ZeroInitialized fZeroInitialized;
scroggob636b452015-07-22 07:16:20 -0700263 /**
264 * If not NULL, represents a subset of the original image to decode.
scroggob636b452015-07-22 07:16:20 -0700265 * Must be within the bounds returned by getInfo().
Hal Canarydb683012016-11-23 08:55:18 -0700266 * If the EncodedFormat is SkEncodedImageFormat::kWEBP (the only one which
scroggob636b452015-07-22 07:16:20 -0700267 * currently supports subsets), the top and left values must be even.
msarettfdb47572015-10-13 12:50:14 -0700268 *
scroggo8e6c7ad2016-09-16 08:20:38 -0700269 * In getPixels and incremental decode, we will attempt to decode the
270 * exact rectangular subset specified by fSubset.
msarettfdb47572015-10-13 12:50:14 -0700271 *
272 * In a scanline decode, it does not make sense to specify a subset
273 * top or subset height, since the client already controls which rows
274 * to get and which rows to skip. During scanline decodes, we will
275 * require that the subset top be zero and the subset height be equal
276 * to the full height. We will, however, use the values of
277 * subset left and subset width to decode partial scanlines on calls
278 * to getScanlines().
scroggob636b452015-07-22 07:16:20 -0700279 */
Matt Sarettcf3f2342017-03-23 15:32:25 -0400280 const SkIRect* fSubset;
scroggo19b91532016-10-24 09:03:26 -0700281
282 /**
283 * The frame to decode.
284 *
285 * Only meaningful for multi-frame images.
286 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400287 int fFrameIndex;
scroggo19b91532016-10-24 09:03:26 -0700288
289 /**
Nigel Tao66bc5242018-08-22 10:56:03 +1000290 * If not kNoFrame, the dst already contains the prior frame at this index.
scroggo19b91532016-10-24 09:03:26 -0700291 *
292 * Only meaningful for multi-frame images.
293 *
294 * If fFrameIndex needs to be blended with a prior frame (as reported by
295 * getFrameInfo[fFrameIndex].fRequiredFrame), the client can set this to
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400296 * any non-kRestorePrevious frame in [fRequiredFrame, fFrameIndex) to
297 * indicate that that frame is already in the dst. Options.fZeroInitialized
298 * is ignored in this case.
scroggo19b91532016-10-24 09:03:26 -0700299 *
Nigel Tao66bc5242018-08-22 10:56:03 +1000300 * If set to kNoFrame, the codec will decode any necessary required frame(s) first.
scroggo19b91532016-10-24 09:03:26 -0700301 */
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400302 int fPriorFrame;
scroggoeb602a52015-07-09 08:16:03 -0700303 };
304
305 /**
306 * Decode into the given pixels, a block of memory of size at
307 * least (info.fHeight - 1) * rowBytes + (info.fWidth *
308 * bytesPerPixel)
309 *
310 * Repeated calls to this function should give the same results,
311 * allowing the PixelRef to be immutable.
312 *
313 * @param info A description of the format (config, size)
314 * expected by the caller. This can simply be identical
315 * to the info returned by getInfo().
316 *
317 * This contract also allows the caller to specify
318 * different output-configs, which the implementation can
319 * decide to support or not.
320 *
321 * A size that does not match getInfo() implies a request
322 * to scale. If the generator cannot perform this scale,
323 * it will return kInvalidScale.
324 *
msarett50ce1f22016-07-29 06:23:33 -0700325 * If the info contains a non-null SkColorSpace, the codec
326 * will perform the appropriate color space transformation.
327 * If the caller passes in the same color space that was
328 * reported by the codec, the color space transformation is
329 * a no-op.
330 *
scroggo46c57472015-09-30 08:57:13 -0700331 * If a scanline decode is in progress, scanline mode will end, requiring the client to call
332 * startScanlineDecode() in order to return to decoding scanlines.
333 *
scroggoeb602a52015-07-09 08:16:03 -0700334 * @return Result kSuccess, or another value explaining the type of failure.
335 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000336 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes, const Options*);
scroggoeb602a52015-07-09 08:16:03 -0700337
338 /**
Leon Scroggins571b30f2017-07-11 17:35:31 +0000339 * Simplified version of getPixels() that uses the default Options.
scroggoeb602a52015-07-09 08:16:03 -0700340 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000341 Result getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes) {
342 return this->getPixels(info, pixels, rowBytes, nullptr);
343 }
scroggoeb602a52015-07-09 08:16:03 -0700344
Mike Reed43798692017-10-17 18:04:32 +0000345 Result getPixels(const SkPixmap& pm, const Options* opts = nullptr) {
346 return this->getPixels(pm.info(), pm.writable_addr(), pm.rowBytes(), opts);
347 }
348
msarettb714fb02016-01-22 14:46:42 -0800349 /**
350 * If decoding to YUV is supported, this returns true. Otherwise, this
351 * returns false and does not modify any of the parameters.
352 *
353 * @param sizeInfo Output parameter indicating the sizes and required
Jim Van Verth8f11e432018-10-18 14:36:59 -0400354 * allocation widths of the Y, U, V, and A planes. Given current codec
355 * limitations the size of the A plane will always be 0 and the Y, U, V
356 * channels will always be planar.
msarettb714fb02016-01-22 14:46:42 -0800357 * @param colorSpace Output parameter. If non-NULL this is set to kJPEG,
358 * otherwise this is ignored.
359 */
Jim Van Verthe24b5872018-10-29 16:26:02 -0400360 bool queryYUV8(SkYUVASizeInfo* sizeInfo, SkYUVColorSpace* colorSpace) const {
msarettb714fb02016-01-22 14:46:42 -0800361 if (nullptr == sizeInfo) {
362 return false;
363 }
364
Jim Van Verth8f11e432018-10-18 14:36:59 -0400365 bool result = this->onQueryYUV8(sizeInfo, colorSpace);
366 if (result) {
367 for (int i = 0; i <= 2; ++i) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400368 SkASSERT(sizeInfo->fSizes[i].fWidth > 0 && sizeInfo->fSizes[i].fHeight > 0 &&
369 sizeInfo->fWidthBytes[i] > 0);
370 }
Jim Van Verth8f11e432018-10-18 14:36:59 -0400371 SkASSERT(!sizeInfo->fSizes[3].fWidth &&
372 !sizeInfo->fSizes[3].fHeight &&
373 !sizeInfo->fWidthBytes[3]);
374 }
375 return result;
msarettb714fb02016-01-22 14:46:42 -0800376 }
377
378 /**
379 * Returns kSuccess, or another value explaining the type of failure.
380 * This always attempts to perform a full decode. If the client only
381 * wants size, it should call queryYUV8().
382 *
383 * @param sizeInfo Needs to exactly match the values returned by the
384 * query, except the WidthBytes may be larger than the
385 * recommendation (but not smaller).
386 * @param planes Memory for each of the Y, U, and V planes.
387 */
Jim Van Verthe24b5872018-10-29 16:26:02 -0400388 Result getYUV8Planes(const SkYUVASizeInfo& sizeInfo, void* planes[SkYUVASizeInfo::kMaxCount]) {
Jim Van Verth8f11e432018-10-18 14:36:59 -0400389 if (!planes || !planes[0] || !planes[1] || !planes[2]) {
msarettb714fb02016-01-22 14:46:42 -0800390 return kInvalidInput;
391 }
Jim Van Verth8f11e432018-10-18 14:36:59 -0400392 SkASSERT(!planes[3]); // TODO: is this a fair assumption?
msarettb714fb02016-01-22 14:46:42 -0800393
394 if (!this->rewindIfNeeded()) {
395 return kCouldNotRewind;
396 }
397
398 return this->onGetYUV8Planes(sizeInfo, planes);
399 }
400
scroggoeb602a52015-07-09 08:16:03 -0700401 /**
scroggo8e6c7ad2016-09-16 08:20:38 -0700402 * Prepare for an incremental decode with the specified options.
403 *
404 * This may require a rewind.
405 *
406 * @param dstInfo Info of the destination. If the dimensions do not match
407 * those of getInfo, this implies a scale.
408 * @param dst Memory to write to. Needs to be large enough to hold the subset,
409 * if present, or the full image as described in dstInfo.
410 * @param options Contains decoding options, including if memory is zero
411 * initialized and whether to decode a subset.
scroggo8e6c7ad2016-09-16 08:20:38 -0700412 * @return Enum representing success or reason for failure.
413 */
414 Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000415 const Options*);
scroggo8e6c7ad2016-09-16 08:20:38 -0700416
417 Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes) {
Leon Scroggins571b30f2017-07-11 17:35:31 +0000418 return this->startIncrementalDecode(dstInfo, dst, rowBytes, nullptr);
scroggo8e6c7ad2016-09-16 08:20:38 -0700419 }
420
421 /**
422 * Start/continue the incremental decode.
423 *
424 * Not valid to call before calling startIncrementalDecode().
425 *
426 * After the first call, should only be called again if more data has been
427 * provided to the source SkStream.
428 *
429 * Unlike getPixels and getScanlines, this does not do any filling. This is
430 * left up to the caller, since they may be skipping lines or continuing the
431 * decode later. In the latter case, they may choose to initialize all lines
432 * first, or only initialize the remaining lines after the first call.
433 *
434 * @param rowsDecoded Optional output variable returning the total number of
435 * lines initialized. Only meaningful if this method returns kIncompleteInput.
436 * Otherwise the implementation may not set it.
437 * Note that some implementations may have initialized this many rows, but
438 * not necessarily finished those rows (e.g. interlaced PNG). This may be
439 * useful for determining what rows the client needs to initialize.
440 * @return kSuccess if all lines requested in startIncrementalDecode have
441 * been completely decoded. kIncompleteInput otherwise.
442 */
443 Result incrementalDecode(int* rowsDecoded = nullptr) {
444 if (!fStartedIncrementalDecode) {
445 return kInvalidParameters;
446 }
447 return this->onIncrementalDecode(rowsDecoded);
448 }
449
450 /**
scroggo46c57472015-09-30 08:57:13 -0700451 * The remaining functions revolve around decoding scanlines.
452 */
453
454 /**
455 * Prepare for a scanline decode with the specified options.
456 *
457 * After this call, this class will be ready to decode the first scanline.
458 *
459 * This must be called in order to call getScanlines or skipScanlines.
460 *
461 * This may require rewinding the stream.
462 *
463 * Not all SkCodecs support this.
464 *
465 * @param dstInfo Info of the destination. If the dimensions do not match
466 * those of getInfo, this implies a scale.
467 * @param options Contains decoding options, including if memory is zero
468 * initialized.
scroggo46c57472015-09-30 08:57:13 -0700469 * @return Enum representing success or reason for failure.
470 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000471 Result startScanlineDecode(const SkImageInfo& dstInfo, const Options* options);
scroggo46c57472015-09-30 08:57:13 -0700472
473 /**
Leon Scroggins571b30f2017-07-11 17:35:31 +0000474 * Simplified version of startScanlineDecode() that uses the default Options.
scroggo46c57472015-09-30 08:57:13 -0700475 */
Leon Scroggins571b30f2017-07-11 17:35:31 +0000476 Result startScanlineDecode(const SkImageInfo& dstInfo) {
477 return this->startScanlineDecode(dstInfo, nullptr);
478 }
scroggo46c57472015-09-30 08:57:13 -0700479
480 /**
481 * Write the next countLines scanlines into dst.
482 *
483 * Not valid to call before calling startScanlineDecode().
484 *
485 * @param dst Must be non-null, and large enough to hold countLines
486 * scanlines of size rowBytes.
487 * @param countLines Number of lines to write.
488 * @param rowBytes Number of bytes per row. Must be large enough to hold
489 * a scanline based on the SkImageInfo used to create this object.
msarette6dd0042015-10-09 11:07:34 -0700490 * @return the number of lines successfully decoded. If this value is
491 * less than countLines, this will fill the remaining lines with a
492 * default value.
scroggo46c57472015-09-30 08:57:13 -0700493 */
msarette6dd0042015-10-09 11:07:34 -0700494 int getScanlines(void* dst, int countLines, size_t rowBytes);
scroggo46c57472015-09-30 08:57:13 -0700495
496 /**
497 * Skip count scanlines.
498 *
499 * Not valid to call before calling startScanlineDecode().
500 *
501 * The default version just calls onGetScanlines and discards the dst.
502 * NOTE: If skipped lines are the only lines with alpha, this default
503 * will make reallyHasAlpha return true, when it could have returned
504 * false.
msarette6dd0042015-10-09 11:07:34 -0700505 *
506 * @return true if the scanlines were successfully skipped
507 * false on failure, possible reasons for failure include:
508 * An incomplete input image stream.
509 * Calling this function before calling startScanlineDecode().
510 * If countLines is less than zero or so large that it moves
511 * the current scanline past the end of the image.
scroggo46c57472015-09-30 08:57:13 -0700512 */
msarette6dd0042015-10-09 11:07:34 -0700513 bool skipScanlines(int countLines);
scroggo46c57472015-09-30 08:57:13 -0700514
515 /**
516 * The order in which rows are output from the scanline decoder is not the
517 * same for all variations of all image types. This explains the possible
518 * output row orderings.
519 */
520 enum SkScanlineOrder {
521 /*
522 * By far the most common, this indicates that the image can be decoded
523 * reliably using the scanline decoder, and that rows will be output in
524 * the logical order.
525 */
526 kTopDown_SkScanlineOrder,
527
528 /*
529 * This indicates that the scanline decoder reliably outputs rows, but
530 * they will be returned in reverse order. If the scanline format is
531 * kBottomUp, the nextScanline() API can be used to determine the actual
532 * y-coordinate of the next output row, but the client is not forced
533 * to take advantage of this, given that it's not too tough to keep
534 * track independently.
535 *
536 * For full image decodes, it is safe to get all of the scanlines at
537 * once, since the decoder will handle inverting the rows as it
538 * decodes.
539 *
540 * For subset decodes and sampling, it is simplest to get and skip
541 * scanlines one at a time, using the nextScanline() API. It is
542 * possible to ask for larger chunks at a time, but this should be used
543 * with caution. As with full image decodes, the decoder will handle
544 * inverting the requested rows, but rows will still be delivered
545 * starting from the bottom of the image.
546 *
547 * Upside down bmps are an example.
548 */
549 kBottomUp_SkScanlineOrder,
scroggo46c57472015-09-30 08:57:13 -0700550 };
551
552 /**
553 * An enum representing the order in which scanlines will be returned by
554 * the scanline decoder.
msarettbe8216a2015-12-04 08:00:50 -0800555 *
556 * This is undefined before startScanlineDecode() is called.
scroggo46c57472015-09-30 08:57:13 -0700557 */
558 SkScanlineOrder getScanlineOrder() const { return this->onGetScanlineOrder(); }
559
560 /**
561 * Returns the y-coordinate of the next row to be returned by the scanline
msarette6dd0042015-10-09 11:07:34 -0700562 * decoder.
563 *
564 * This will equal fCurrScanline, except in the case of strangely
scroggo19b91532016-10-24 09:03:26 -0700565 * encoded image types (bottom-up bmps).
scroggo46c57472015-09-30 08:57:13 -0700566 *
567 * Results are undefined when not in scanline decoding mode.
568 */
msarette6dd0042015-10-09 11:07:34 -0700569 int nextScanline() const { return this->outputScanline(fCurrScanline); }
570
571 /**
msarettcb0d5c92015-12-03 12:23:43 -0800572 * Returns the output y-coordinate of the row that corresponds to an input
573 * y-coordinate. The input y-coordinate represents where the scanline
574 * is located in the encoded data.
msarette6dd0042015-10-09 11:07:34 -0700575 *
576 * This will equal inputScanline, except in the case of strangely
577 * encoded image types (bottom-up bmps, interlaced gifs).
578 */
579 int outputScanline(int inputScanline) const;
scroggo46c57472015-09-30 08:57:13 -0700580
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400581 /**
582 * Return the number of frames in the image.
583 *
584 * May require reading through the stream.
585 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400586 int getFrameCount() {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400587 return this->onGetFrameCount();
588 }
589
Nigel Tao66bc5242018-08-22 10:56:03 +1000590 // Sentinel value used when a frame index implies "no frame":
591 // - FrameInfo::fRequiredFrame set to this value means the frame
592 // is independent.
593 // - Options::fPriorFrame set to this value means no (relevant) prior frame
594 // is residing in dst's memory.
595 static constexpr int kNoFrame = -1;
596
Mike Kleineb4d6412018-11-12 16:08:30 +0000597 // This transitional definition was added in August 2018, and will eventually be removed.
598#ifdef SK_LEGACY_SKCODEC_NONE_ENUM
599 static constexpr int kNone = kNoFrame;
600#endif
601
scroggo19b91532016-10-24 09:03:26 -0700602 /**
603 * Information about individual frames in a multi-framed image.
604 */
605 struct FrameInfo {
606 /**
607 * The frame that this frame needs to be blended with, or
Nigel Tao66bc5242018-08-22 10:56:03 +1000608 * kNoFrame if this frame is independent.
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400609 *
610 * Note that this is the *earliest* frame that can be used
611 * for blending. Any frame from [fRequiredFrame, i) can be
612 * used, unless its fDisposalMethod is kRestorePrevious.
scroggo19b91532016-10-24 09:03:26 -0700613 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400614 int fRequiredFrame;
scroggo19b91532016-10-24 09:03:26 -0700615
616 /**
617 * Number of milliseconds to show this frame.
618 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400619 int fDuration;
Leon Scroggins III3639faa2016-12-08 11:38:58 -0500620
621 /**
622 * Whether the end marker for this frame is contained in the stream.
623 *
624 * Note: this does not guarantee that an attempt to decode will be complete.
625 * There could be an error in the stream.
626 */
627 bool fFullyReceived;
Leon Scroggins IIIa4db9be2017-04-11 10:32:02 -0400628
629 /**
630 * This is conservative; it will still return non-opaque if e.g. a
631 * color index-based frame has a color with alpha but does not use it.
632 */
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500633 SkAlphaType fAlphaType;
Leon Scroggins III33deb7e2017-06-07 12:31:51 -0400634
635 /**
636 * How this frame should be modified before decoding the next one.
637 */
638 SkCodecAnimation::DisposalMethod fDisposalMethod;
scroggo19b91532016-10-24 09:03:26 -0700639 };
640
641 /**
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400642 * Return info about a single frame.
643 *
644 * Only supported by multi-frame images. Does not read through the stream,
645 * so it should be called after getFrameCount() to parse any frames that
646 * have not already been parsed.
647 */
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400648 bool getFrameInfo(int index, FrameInfo* info) const {
Leon Scroggins III557fbbe2017-05-23 09:37:21 -0400649 if (index < 0) {
650 return false;
651 }
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400652 return this->onGetFrameInfo(index, info);
653 }
654
655 /**
656 * Return info about all the frames in the image.
scroggo19b91532016-10-24 09:03:26 -0700657 *
scroggoe71b1a12016-11-01 08:28:28 -0700658 * May require reading through the stream to determine info about the
659 * frames (including the count).
scroggo19b91532016-10-24 09:03:26 -0700660 *
661 * As such, future decoding calls may require a rewind.
662 *
Nigel Tao96597c22018-08-22 10:36:12 +1000663 * For still (non-animated) image codecs, this will return an empty vector.
scroggo19b91532016-10-24 09:03:26 -0700664 */
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400665 std::vector<FrameInfo> getFrameInfo();
scroggo19b91532016-10-24 09:03:26 -0700666
scroggoe71b1a12016-11-01 08:28:28 -0700667 static constexpr int kRepetitionCountInfinite = -1;
668
669 /**
Nigel Tao96597c22018-08-22 10:36:12 +1000670 * Return the number of times to repeat, if this image is animated. This number does not
671 * include the first play through of each frame. For example, a repetition count of 4 means
672 * that each frame is played 5 times and then the animation stops.
673 *
674 * It can return kRepetitionCountInfinite, a negative number, meaning that the animation
675 * should loop forever.
scroggoe71b1a12016-11-01 08:28:28 -0700676 *
677 * May require reading the stream to find the repetition count.
678 *
679 * As such, future decoding calls may require a rewind.
680 *
Nigel Tao96597c22018-08-22 10:36:12 +1000681 * For still (non-animated) image codecs, this will return 0.
scroggoe71b1a12016-11-01 08:28:28 -0700682 */
683 int getRepetitionCount() {
684 return this->onGetRepetitionCount();
685 }
686
scroggof24f2242015-03-03 08:59:20 -0800687protected:
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500688 const SkEncodedInfo& getEncodedInfo() const { return fEncodedInfo; }
689
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400690 using XformFormat = skcms_PixelFormat;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400691
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400692 SkCodec(SkEncodedInfo&&,
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400693 XformFormat srcFormat,
Mike Reedede7bac2017-07-23 15:30:02 -0400694 std::unique_ptr<SkStream>,
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400695 SkEncodedOrigin = kTopLeft_SkEncodedOrigin);
msarett549ca322016-08-17 08:54:08 -0700696
msarettb714fb02016-01-22 14:46:42 -0800697 virtual SkISize onGetScaledDimensions(float /*desiredScale*/) const {
scroggof24f2242015-03-03 08:59:20 -0800698 // By default, scaling is not supported.
Leon Scroggins III712476e2018-10-03 15:47:00 -0400699 return this->dimensions();
scroggof24f2242015-03-03 08:59:20 -0800700 }
701
scroggoe7fc14b2015-10-02 13:14:46 -0700702 // FIXME: What to do about subsets??
703 /**
704 * Subclasses should override if they support dimensions other than the
705 * srcInfo's.
706 */
707 virtual bool onDimensionsSupported(const SkISize&) {
708 return false;
709 }
710
Hal Canarydb683012016-11-23 08:55:18 -0700711 virtual SkEncodedImageFormat onGetEncodedFormat() const = 0;
scroggo1dd3ea92015-03-20 11:55:55 -0700712
msarette6dd0042015-10-09 11:07:34 -0700713 /**
714 * @param rowsDecoded When the encoded image stream is incomplete, this function
715 * will return kIncompleteInput and rowsDecoded will be set to
716 * the number of scanlines that were successfully decoded.
717 * This will allow getPixels() to fill the uninitialized memory.
718 */
scroggoeb602a52015-07-09 08:16:03 -0700719 virtual Result onGetPixels(const SkImageInfo& info,
720 void* pixels, size_t rowBytes, const Options&,
msarette6dd0042015-10-09 11:07:34 -0700721 int* rowsDecoded) = 0;
scroggoeb602a52015-07-09 08:16:03 -0700722
Jim Van Verthe24b5872018-10-29 16:26:02 -0400723 virtual bool onQueryYUV8(SkYUVASizeInfo*, SkYUVColorSpace*) const {
msarettb714fb02016-01-22 14:46:42 -0800724 return false;
725 }
726
Jim Van Verthe24b5872018-10-29 16:26:02 -0400727 virtual Result onGetYUV8Planes(const SkYUVASizeInfo&,
728 void*[SkYUVASizeInfo::kMaxCount] /*planes*/) {
msarettb714fb02016-01-22 14:46:42 -0800729 return kUnimplemented;
730 }
731
732 virtual bool onGetValidSubset(SkIRect* /*desiredSubset*/) const {
scroggob636b452015-07-22 07:16:20 -0700733 // By default, subsets are not supported.
734 return false;
735 }
736
msarett90c4d5f2015-12-10 13:09:24 -0800737 /**
scroggof24f2242015-03-03 08:59:20 -0800738 * If the stream was previously read, attempt to rewind.
scroggob427db12015-08-12 07:24:13 -0700739 *
740 * If the stream needed to be rewound, call onRewind.
741 * @returns true if the codec is at the right position and can be used.
742 * false if there was a failure to rewind.
halcanarya096d7a2015-03-27 12:16:53 -0700743 *
Nigel Tao13df9812018-08-08 14:33:58 +1000744 * This is called by getPixels(), getYUV8Planes(), startIncrementalDecode() and
745 * startScanlineDecode(). Subclasses may call if they need to rewind at another time.
scroggof24f2242015-03-03 08:59:20 -0800746 */
scroggob427db12015-08-12 07:24:13 -0700747 bool SK_WARN_UNUSED_RESULT rewindIfNeeded();
748
749 /**
750 * Called by rewindIfNeeded, if the stream needed to be rewound.
751 *
752 * Subclasses should do any set up needed after a rewind.
753 */
754 virtual bool onRewind() {
755 return true;
756 }
scroggof24f2242015-03-03 08:59:20 -0800757
msarettc0e80c12015-07-01 06:50:35 -0700758 /**
msarett74114382015-03-16 11:55:18 -0700759 * Get method for the input stream
msarett74114382015-03-16 11:55:18 -0700760 */
761 SkStream* stream() {
762 return fStream.get();
763 }
764
scroggo46c57472015-09-30 08:57:13 -0700765 /**
766 * The remaining functions revolve around decoding scanlines.
767 */
768
769 /**
770 * Most images types will be kTopDown and will not need to override this function.
771 */
772 virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; }
773
scroggo46c57472015-09-30 08:57:13 -0700774 const SkImageInfo& dstInfo() const { return fDstInfo; }
775
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400776 const Options& options() const { return fOptions; }
scroggo46c57472015-09-30 08:57:13 -0700777
msarettcb0d5c92015-12-03 12:23:43 -0800778 /**
779 * Returns the number of scanlines that have been decoded so far.
780 * This is unaffected by the SkScanlineOrder.
781 *
782 * Returns -1 if we have not started a scanline decode.
783 */
784 int currScanline() const { return fCurrScanline; }
785
msarette6dd0042015-10-09 11:07:34 -0700786 virtual int onOutputScanline(int inputScanline) const;
787
Leon Scroggins III9b0ba2c2018-11-19 14:52:37 -0500788 /**
789 * Return whether we can convert to dst.
790 *
791 * Will be called for the appropriate frame, prior to initializing the colorXform.
792 */
793 virtual bool conversionSupported(const SkImageInfo& dst, bool srcIsOpaque,
794 bool needsColorXform);
795
Leon Scroggins IIIae79f322017-08-18 10:53:24 -0400796 // Some classes never need a colorXform e.g.
797 // - ICO uses its embedded codec's colorXform
798 // - WBMP is just Black/White
799 virtual bool usesColorXform() const { return true; }
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400800 void applyColorXform(void* dst, const void* src, int count) const;
801
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400802 bool colorXform() const { return fXformTime != kNo_XformTime; }
803 bool xformOnDecode() const { return fXformTime == kDecodeRow_XformTime; }
Matt Sarett313c4632016-10-20 12:35:23 -0400804
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400805 virtual int onGetFrameCount() {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400806 return 1;
807 }
808
Leon Scroggins III249b8e32017-04-17 12:46:33 -0400809 virtual bool onGetFrameInfo(int, FrameInfo*) const {
Leon Scroggins IIIe132e7b2017-04-12 10:49:52 -0400810 return false;
scroggo19b91532016-10-24 09:03:26 -0700811 }
812
scroggoe71b1a12016-11-01 08:28:28 -0700813 virtual int onGetRepetitionCount() {
814 return 0;
815 }
816
Matt Sarett313c4632016-10-20 12:35:23 -0400817private:
818 const SkEncodedInfo fEncodedInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400819 const XformFormat fSrcXformFormat;
bungeman6bd52842016-10-27 09:30:08 -0700820 std::unique_ptr<SkStream> fStream;
Matt Sarett313c4632016-10-20 12:35:23 -0400821 bool fNeedsRewind;
Leon Scroggins IIIb6ab10f2017-10-18 14:42:43 -0400822 const SkEncodedOrigin fOrigin;
Matt Sarett313c4632016-10-20 12:35:23 -0400823
824 SkImageInfo fDstInfo;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400825 Options fOptions;
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400826
827 enum XformTime {
828 kNo_XformTime,
829 kPalette_XformTime,
830 kDecodeRow_XformTime,
831 };
832 XformTime fXformTime;
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400833 XformFormat fDstXformFormat; // Based on fDstInfo.
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400834 skcms_ICCProfile fDstProfile;
835 skcms_AlphaFormat fDstXformAlphaFormat;
scroggo8e6c7ad2016-09-16 08:20:38 -0700836
837 // Only meaningful during scanline decodes.
Matt Sarett313c4632016-10-20 12:35:23 -0400838 int fCurrScanline;
scroggo46c57472015-09-30 08:57:13 -0700839
Matt Sarett313c4632016-10-20 12:35:23 -0400840 bool fStartedIncrementalDecode;
scroggo8e6c7ad2016-09-16 08:20:38 -0700841
Leon Scroggins III36f7e322018-08-27 11:55:46 -0400842 bool initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Alpha, bool srcIsOpaque);
843
Leon Scroggins III07418182017-08-15 12:24:02 -0400844 /**
scroggoe7fc14b2015-10-02 13:14:46 -0700845 * Return whether these dimensions are supported as a scale.
846 *
847 * The codec may choose to cache the information about scale and subset.
848 * Either way, the same information will be passed to onGetPixels/onStart
849 * on success.
850 *
851 * This must return true for a size returned from getScaledDimensions.
852 */
853 bool dimensionsSupported(const SkISize& dim) {
Leon Scroggins III712476e2018-10-03 15:47:00 -0400854 return dim == this->dimensions() || this->onDimensionsSupported(dim);
scroggoe7fc14b2015-10-02 13:14:46 -0700855 }
856
Leon Scroggins III1f6af6b2017-06-12 16:41:09 -0400857 /**
858 * For multi-framed images, return the object with information about the frames.
859 */
860 virtual const SkFrameHolder* getFrameHolder() const {
861 return nullptr;
862 }
863
864 /**
865 * Check for a valid Options.fFrameIndex, and decode prior frames if necessary.
866 */
867 Result handleFrameIndex(const SkImageInfo&, void* pixels, size_t rowBytes, const Options&);
868
scroggo46c57472015-09-30 08:57:13 -0700869 // Methods for scanline decoding.
Leon Scroggins IIIc6e6a5f2017-06-05 15:53:38 -0400870 virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000871 const Options& /*options*/) {
scroggo46c57472015-09-30 08:57:13 -0700872 return kUnimplemented;
873 }
874
scroggo8e6c7ad2016-09-16 08:20:38 -0700875 virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
Leon Scroggins571b30f2017-07-11 17:35:31 +0000876 const Options&) {
scroggo8e6c7ad2016-09-16 08:20:38 -0700877 return kUnimplemented;
878 }
879
880 virtual Result onIncrementalDecode(int*) {
881 return kUnimplemented;
882 }
883
884
msarett9b9497e2016-02-11 13:29:36 -0800885 virtual bool onSkipScanlines(int /*countLines*/) { return false; }
scroggo46c57472015-09-30 08:57:13 -0700886
msarett33bee092015-11-11 12:43:07 -0800887 virtual int onGetScanlines(void* /*dst*/, int /*countLines*/, size_t /*rowBytes*/) { return 0; }
msarette6dd0042015-10-09 11:07:34 -0700888
889 /**
890 * On an incomplete decode, getPixels() and getScanlines() will call this function
891 * to fill any uinitialized memory.
892 *
893 * @param dstInfo Contains the destination color type
894 * Contains the destination alpha type
895 * Contains the destination width
896 * The height stored in this info is unused
897 * @param dst Pointer to the start of destination pixel memory
898 * @param rowBytes Stride length in destination pixel memory
899 * @param zeroInit Indicates if memory is zero initialized
900 * @param linesRequested Number of lines that the client requested
901 * @param linesDecoded Number of lines that were successfully decoded
902 */
903 void fillIncompleteImage(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
904 ZeroInitialized zeroInit, int linesRequested, int linesDecoded);
scroggo46c57472015-09-30 08:57:13 -0700905
scroggoe7fc14b2015-10-02 13:14:46 -0700906 /**
907 * Return an object which will allow forcing scanline decodes to sample in X.
908 *
909 * May create a sampler, if one is not currently being used. Otherwise, does
910 * not affect ownership.
911 *
scroggo19b91532016-10-24 09:03:26 -0700912 * Only valid during scanline decoding or incremental decoding.
scroggoe7fc14b2015-10-02 13:14:46 -0700913 */
msarett33bee092015-11-11 12:43:07 -0800914 virtual SkSampler* getSampler(bool /*createIfNecessary*/) { return nullptr; }
scroggoe7fc14b2015-10-02 13:14:46 -0700915
scroggo8e6c7ad2016-09-16 08:20:38 -0700916 friend class DM::CodecSrc; // for fillIncompleteImage
msarett3d9d7a72015-10-21 10:27:10 -0700917 friend class SkSampledCodec;
msarettbe8216a2015-12-04 08:00:50 -0800918 friend class SkIcoCodec;
Leon Scroggins IIIc8037dc2017-12-05 13:55:24 -0500919 friend class SkAndroidCodec; // for fEncodedInfo
scroggof24f2242015-03-03 08:59:20 -0800920};
921#endif // SkCodec_DEFINED