1 /*
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 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h"
10 #include "SkColorTable.h"
11 #include "SkGifCodec.h"
12 #include "SkStream.h"
13 #include "SkSwizzler.h"
14 #include "SkUtils.h"
15
16 #include "gif_lib.h"
17
18 /*
19 * Checks the start of the stream to see if the image is a gif
20 */
IsGif(const void * buf,size_t bytesRead)21 bool SkGifCodec::IsGif(const void* buf, size_t bytesRead) {
22 if (bytesRead >= GIF_STAMP_LEN) {
23 if (memcmp(GIF_STAMP, buf, GIF_STAMP_LEN) == 0 ||
24 memcmp(GIF87_STAMP, buf, GIF_STAMP_LEN) == 0 ||
25 memcmp(GIF89_STAMP, buf, GIF_STAMP_LEN) == 0)
26 {
27 return true;
28 }
29 }
30 return false;
31 }
32
33 /*
34 * Error function
35 */
gif_error(const char * msg,SkCodec::Result result=SkCodec::kInvalidInput)36 static SkCodec::Result gif_error(const char* msg, SkCodec::Result result = SkCodec::kInvalidInput) {
37 SkCodecPrintf("Gif Error: %s\n", msg);
38 return result;
39 }
40
41
42 /*
43 * Read function that will be passed to gif_lib
44 */
read_bytes_callback(GifFileType * fileType,GifByteType * out,int32_t size)45 static int32_t read_bytes_callback(GifFileType* fileType, GifByteType* out, int32_t size) {
46 SkStream* stream = (SkStream*) fileType->UserData;
47 return (int32_t) stream->read(out, size);
48 }
49
50 /*
51 * Open the gif file
52 */
open_gif(SkStream * stream)53 static GifFileType* open_gif(SkStream* stream) {
54 #if GIFLIB_MAJOR < 5
55 return DGifOpen(stream, read_bytes_callback);
56 #else
57 return DGifOpen(stream, read_bytes_callback, nullptr);
58 #endif
59 }
60
61 /*
62 * Check if a there is an index of the color table for a transparent pixel
63 */
find_trans_index(const SavedImage & image)64 static uint32_t find_trans_index(const SavedImage& image) {
65 // If there is a transparent index specified, it will be contained in an
66 // extension block. We will loop through extension blocks in reverse order
67 // to check the most recent extension blocks first.
68 for (int32_t i = image.ExtensionBlockCount - 1; i >= 0; i--) {
69 // Get an extension block
70 const ExtensionBlock& extBlock = image.ExtensionBlocks[i];
71
72 // Specifically, we need to check for a graphics control extension,
73 // which may contain transparency information. Also, note that a valid
74 // graphics control extension is always four bytes. The fourth byte
75 // is the transparent index (if it exists), so we need at least four
76 // bytes.
77 if (GRAPHICS_EXT_FUNC_CODE == extBlock.Function && extBlock.ByteCount >= 4) {
78 // Check the transparent color flag which indicates whether a
79 // transparent index exists. It is the least significant bit of
80 // the first byte of the extension block.
81 if (1 == (extBlock.Bytes[0] & 1)) {
82 // Use uint32_t to prevent sign extending
83 return extBlock.Bytes[3];
84 }
85
86 // There should only be one graphics control extension for the image frame
87 break;
88 }
89 }
90
91 // Use maximum unsigned int (surely an invalid index) to indicate that a valid
92 // index was not found.
93 return SK_MaxU32;
94 }
95
ceil_div(uint32_t a,uint32_t b)96 inline uint32_t ceil_div(uint32_t a, uint32_t b) {
97 return (a + b - 1) / b;
98 }
99
100 /*
101 * Gets the output row corresponding to the encoded row for interlaced gifs
102 */
get_output_row_interlaced(uint32_t encodedRow,uint32_t height)103 inline uint32_t get_output_row_interlaced(uint32_t encodedRow, uint32_t height) {
104 SkASSERT(encodedRow < height);
105 // First pass
106 if (encodedRow * 8 < height) {
107 return encodedRow * 8;
108 }
109 // Second pass
110 if (encodedRow * 4 < height) {
111 return 4 + 8 * (encodedRow - ceil_div(height, 8));
112 }
113 // Third pass
114 if (encodedRow * 2 < height) {
115 return 2 + 4 * (encodedRow - ceil_div(height, 4));
116 }
117 // Fourth pass
118 return 1 + 2 * (encodedRow - ceil_div(height, 2));
119 }
120
121 /*
122 * This function cleans up the gif object after the decode completes
123 * It is used in a SkAutoTCallIProc template
124 */
CloseGif(GifFileType * gif)125 void SkGifCodec::CloseGif(GifFileType* gif) {
126 #if GIFLIB_MAJOR < 5 || (GIFLIB_MAJOR == 5 && GIFLIB_MINOR == 0)
127 DGifCloseFile(gif);
128 #else
129 DGifCloseFile(gif, nullptr);
130 #endif
131 }
132
133 /*
134 * This function free extension data that has been saved to assist the image
135 * decoder
136 */
FreeExtension(SavedImage * image)137 void SkGifCodec::FreeExtension(SavedImage* image) {
138 if (NULL != image->ExtensionBlocks) {
139 #if GIFLIB_MAJOR < 5
140 FreeExtension(image);
141 #else
142 GifFreeExtensions(&image->ExtensionBlockCount, &image->ExtensionBlocks);
143 #endif
144 }
145 }
146
147 /*
148 * Read enough of the stream to initialize the SkGifCodec.
149 * Returns a bool representing success or failure.
150 *
151 * @param codecOut
152 * If it returned true, and codecOut was not nullptr,
153 * codecOut will be set to a new SkGifCodec.
154 *
155 * @param gifOut
156 * If it returned true, and codecOut was nullptr,
157 * gifOut must be non-nullptr and gifOut will be set to a new
158 * GifFileType pointer.
159 *
160 * @param stream
161 * Deleted on failure.
162 * codecOut will take ownership of it in the case where we created a codec.
163 * Ownership is unchanged when we returned a gifOut.
164 *
165 */
ReadHeader(SkStream * stream,SkCodec ** codecOut,GifFileType ** gifOut)166 bool SkGifCodec::ReadHeader(SkStream* stream, SkCodec** codecOut, GifFileType** gifOut) {
167 SkAutoTDelete<SkStream> streamDeleter(stream);
168
169 // Read gif header, logical screen descriptor, and global color table
170 SkAutoTCallVProc<GifFileType, CloseGif> gif(open_gif(stream));
171
172 if (nullptr == gif) {
173 gif_error("DGifOpen failed.\n");
174 return false;
175 }
176
177 // Read through gif extensions to get to the image data. Set the
178 // transparent index based on the extension data.
179 uint32_t transIndex;
180 SkCodec::Result result = ReadUpToFirstImage(gif, &transIndex);
181 if (kSuccess != result){
182 return false;
183 }
184
185 // Read the image descriptor
186 if (GIF_ERROR == DGifGetImageDesc(gif)) {
187 return false;
188 }
189 // If reading the image descriptor is successful, the image count will be
190 // incremented.
191 SkASSERT(gif->ImageCount >= 1);
192
193 if (nullptr != codecOut) {
194 SkISize size;
195 SkIRect frameRect;
196 if (!GetDimensions(gif, &size, &frameRect)) {
197 gif_error("Invalid gif size.\n");
198 return false;
199 }
200 bool frameIsSubset = (size != frameRect.size());
201
202 // Determine the encoded alpha type. The transIndex might be valid if it less
203 // than 256. We are not certain that the index is valid until we process the color
204 // table, since some gifs have color tables with less than 256 colors. If
205 // there might be a valid transparent index, we must indicate that the image has
206 // alpha.
207 // In the case where we must support alpha, we indicate kBinary, since every
208 // pixel will either be fully opaque or fully transparent.
209 SkEncodedInfo::Alpha alpha = (transIndex < 256) ? SkEncodedInfo::kBinary_Alpha :
210 SkEncodedInfo::kOpaque_Alpha;
211
212 // Return the codec
213 // Use kPalette since Gifs are encoded with a color table.
214 // Use 8-bits per component, since this is the output we get from giflib.
215 // FIXME: Gifs can actually be encoded with 4-bits per pixel. Can we support this?
216 SkEncodedInfo info = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color, alpha, 8);
217 *codecOut = new SkGifCodec(size.width(), size.height(), info, streamDeleter.release(),
218 gif.release(), transIndex, frameRect, frameIsSubset);
219 } else {
220 SkASSERT(nullptr != gifOut);
221 streamDeleter.release();
222 *gifOut = gif.release();
223 }
224 return true;
225 }
226
227 /*
228 * Assumes IsGif was called and returned true
229 * Creates a gif decoder
230 * Reads enough of the stream to determine the image format
231 */
NewFromStream(SkStream * stream)232 SkCodec* SkGifCodec::NewFromStream(SkStream* stream) {
233 SkCodec* codec = nullptr;
234 if (ReadHeader(stream, &codec, nullptr)) {
235 return codec;
236 }
237 return nullptr;
238 }
239
SkGifCodec(int width,int height,const SkEncodedInfo & info,SkStream * stream,GifFileType * gif,uint32_t transIndex,const SkIRect & frameRect,bool frameIsSubset)240 SkGifCodec::SkGifCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
241 GifFileType* gif, uint32_t transIndex, const SkIRect& frameRect, bool frameIsSubset)
242 : INHERITED(width, height, info, stream)
243 , fGif(gif)
244 , fSrcBuffer(new uint8_t[this->getInfo().width()])
245 , fFrameRect(frameRect)
246 // If it is valid, fTransIndex will be used to set fFillIndex. We don't know if
247 // fTransIndex is valid until we process the color table, since fTransIndex may
248 // be greater than the size of the color table.
249 , fTransIndex(transIndex)
250 // Default fFillIndex is 0. We will overwrite this if fTransIndex is valid, or if
251 // there is a valid background color.
252 , fFillIndex(0)
253 , fFrameIsSubset(frameIsSubset)
254 , fSwizzler(NULL)
255 , fColorTable(NULL)
256 {}
257
onRewind()258 bool SkGifCodec::onRewind() {
259 GifFileType* gifOut = nullptr;
260 if (!ReadHeader(this->stream(), nullptr, &gifOut)) {
261 return false;
262 }
263
264 SkASSERT(nullptr != gifOut);
265 fGif.reset(gifOut);
266 return true;
267 }
268
ReadUpToFirstImage(GifFileType * gif,uint32_t * transIndex)269 SkCodec::Result SkGifCodec::ReadUpToFirstImage(GifFileType* gif, uint32_t* transIndex) {
270 // Use this as a container to hold information about any gif extension
271 // blocks. This generally stores transparency and animation instructions.
272 SavedImage saveExt;
273 SkAutoTCallVProc<SavedImage, FreeExtension> autoFreeExt(&saveExt);
274 saveExt.ExtensionBlocks = nullptr;
275 saveExt.ExtensionBlockCount = 0;
276 GifByteType* extData;
277 int32_t extFunction;
278
279 // We will loop over components of gif images until we find an image. Once
280 // we find an image, we will decode and return it. While many gif files
281 // contain more than one image, we will simply decode the first image.
282 GifRecordType recordType;
283 do {
284 // Get the current record type
285 if (GIF_ERROR == DGifGetRecordType(gif, &recordType)) {
286 return gif_error("DGifGetRecordType failed.\n", kInvalidInput);
287 }
288 switch (recordType) {
289 case IMAGE_DESC_RECORD_TYPE: {
290 *transIndex = find_trans_index(saveExt);
291
292 // FIXME: Gif files may have multiple images stored in a single
293 // file. This is most commonly used to enable
294 // animations. Since we are leaving animated gifs as a
295 // TODO, we will return kSuccess after decoding the
296 // first image in the file. This is the same behavior
297 // as SkImageDecoder_libgif.
298 //
299 // Most times this works pretty well, but sometimes it
300 // doesn't. For example, I have an animated test image
301 // where the first image in the file is 1x1, but the
302 // subsequent images are meaningful. This currently
303 // displays the 1x1 image, which is not ideal. Right
304 // now I am leaving this as an issue that will be
305 // addressed when we implement animated gifs.
306 //
307 // It is also possible (not explicitly disallowed in the
308 // specification) that gif files provide multiple
309 // images in a single file that are all meant to be
310 // displayed in the same frame together. I will
311 // currently leave this unimplemented until I find a
312 // test case that expects this behavior.
313 return kSuccess;
314 }
315 // Extensions are used to specify special properties of the image
316 // such as transparency or animation.
317 case EXTENSION_RECORD_TYPE:
318 // Read extension data
319 if (GIF_ERROR == DGifGetExtension(gif, &extFunction, &extData)) {
320 return gif_error("Could not get extension.\n", kIncompleteInput);
321 }
322
323 // Create an extension block with our data
324 while (nullptr != extData) {
325 // Add a single block
326
327 #if GIFLIB_MAJOR < 5
328 if (AddExtensionBlock(&saveExt, extData[0],
329 &extData[1]) == GIF_ERROR) {
330 #else
331 if (GIF_ERROR == GifAddExtensionBlock(&saveExt.ExtensionBlockCount,
332 &saveExt.ExtensionBlocks,
333 extFunction, extData[0], &extData[1])) {
334 #endif
335 return gif_error("Could not add extension block.\n", kIncompleteInput);
336 }
337 // Move to the next block
338 if (GIF_ERROR == DGifGetExtensionNext(gif, &extData)) {
339 return gif_error("Could not get next extension.\n", kIncompleteInput);
340 }
341 }
342 break;
343
344 // Signals the end of the gif file
345 case TERMINATE_RECORD_TYPE:
346 break;
347
348 default:
349 // DGifGetRecordType returns an error if the record type does
350 // not match one of the above cases. This should not be
351 // reached.
352 SkASSERT(false);
353 break;
354 }
355 } while (TERMINATE_RECORD_TYPE != recordType);
356
357 return gif_error("Could not find any images to decode in gif file.\n", kInvalidInput);
358 }
359
360 bool SkGifCodec::GetDimensions(GifFileType* gif, SkISize* size, SkIRect* frameRect) {
361 // Get the encoded dimension values
362 SavedImage* image = &gif->SavedImages[gif->ImageCount - 1];
363 const GifImageDesc& desc = image->ImageDesc;
364 int frameLeft = desc.Left;
365 int frameTop = desc.Top;
366 int frameWidth = desc.Width;
367 int frameHeight = desc.Height;
368 int width = gif->SWidth;
369 int height = gif->SHeight;
370
371 // Ensure that the decode dimensions are large enough to contain the frame
372 width = SkTMax(width, frameWidth + frameLeft);
373 height = SkTMax(height, frameHeight + frameTop);
374
375 // All of these dimensions should be positive, as they are encoded as unsigned 16-bit integers.
376 // It is unclear why giflib casts them to ints. We will go ahead and check that they are
377 // in fact positive.
378 if (frameLeft < 0 || frameTop < 0 || frameWidth < 0 || frameHeight < 0 || width <= 0 ||
379 height <= 0) {
380 return false;
381 }
382
383 frameRect->setXYWH(frameLeft, frameTop, frameWidth, frameHeight);
384 size->set(width, height);
385 return true;
386 }
387
388 void SkGifCodec::initializeColorTable(const SkImageInfo& dstInfo, SkPMColor* inputColorPtr,
389 int* inputColorCount) {
390 // Set up our own color table
391 const uint32_t maxColors = 256;
392 SkPMColor colorPtr[256];
393 if (NULL != inputColorCount) {
394 // We set the number of colors to maxColors in order to ensure
395 // safe memory accesses. Otherwise, an invalid pixel could
396 // access memory outside of our color table array.
397 *inputColorCount = maxColors;
398 }
399
400 // Get local color table
401 ColorMapObject* colorMap = fGif->Image.ColorMap;
402 // If there is no local color table, use the global color table
403 if (NULL == colorMap) {
404 colorMap = fGif->SColorMap;
405 }
406
407 uint32_t colorCount = 0;
408 if (NULL != colorMap) {
409 colorCount = colorMap->ColorCount;
410 // giflib guarantees these properties
411 SkASSERT(colorCount == (unsigned) (1 << (colorMap->BitsPerPixel)));
412 SkASSERT(colorCount <= 256);
413 PackColorProc proc = choose_pack_color_proc(false, dstInfo.colorType());
414 for (uint32_t i = 0; i < colorCount; i++) {
415 colorPtr[i] = proc(0xFF, colorMap->Colors[i].Red,
416 colorMap->Colors[i].Green, colorMap->Colors[i].Blue);
417 }
418 }
419
420 // Fill in the color table for indices greater than color count.
421 // This allows for predictable, safe behavior.
422 if (colorCount > 0) {
423 // Gifs have the option to specify the color at a single index of the color
424 // table as transparent. If the transparent index is greater than the
425 // colorCount, we know that there is no valid transparent color in the color
426 // table. If there is not valid transparent index, we will try to use the
427 // backgroundIndex as the fill index. If the backgroundIndex is also not
428 // valid, we will let fFillIndex default to 0 (it is set to zero in the
429 // constructor). This behavior is not specified but matches
430 // SkImageDecoder_libgif.
431 uint32_t backgroundIndex = fGif->SBackGroundColor;
432 if (fTransIndex < colorCount) {
433 colorPtr[fTransIndex] = SK_ColorTRANSPARENT;
434 fFillIndex = fTransIndex;
435 } else if (backgroundIndex < colorCount) {
436 fFillIndex = backgroundIndex;
437 }
438
439 for (uint32_t i = colorCount; i < maxColors; i++) {
440 colorPtr[i] = colorPtr[fFillIndex];
441 }
442 } else {
443 sk_memset32(colorPtr, 0xFF000000, maxColors);
444 }
445
446 fColorTable.reset(new SkColorTable(colorPtr, maxColors));
447 copy_color_table(dstInfo, this->fColorTable, inputColorPtr, inputColorCount);
448 }
449
450 SkCodec::Result SkGifCodec::prepareToDecode(const SkImageInfo& dstInfo, SkPMColor* inputColorPtr,
451 int* inputColorCount, const Options& opts) {
452 // Check for valid input parameters
453 if (!conversion_possible_ignore_color_space(dstInfo, this->getInfo())) {
454 return gif_error("Cannot convert input type to output type.\n", kInvalidConversion);
455 }
456
457 // Initialize color table and copy to the client if necessary
458 this->initializeColorTable(dstInfo, inputColorPtr, inputColorCount);
459
460 this->initializeSwizzler(dstInfo, opts);
461 return kSuccess;
462 }
463
464 void SkGifCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) {
465 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
466 const SkIRect* frameRect = fFrameIsSubset ? &fFrameRect : nullptr;
467 fSwizzler.reset(SkSwizzler::CreateSwizzler(this->getEncodedInfo(), colorPtr, dstInfo, opts,
468 frameRect));
469 SkASSERT(fSwizzler);
470 }
471
472 bool SkGifCodec::readRow() {
473 return GIF_ERROR != DGifGetLine(fGif, fSrcBuffer.get(), fFrameRect.width());
474 }
475
476 /*
477 * Initiates the gif decode
478 */
479 SkCodec::Result SkGifCodec::onGetPixels(const SkImageInfo& dstInfo,
480 void* dst, size_t dstRowBytes,
481 const Options& opts,
482 SkPMColor* inputColorPtr,
483 int* inputColorCount,
484 int* rowsDecoded) {
485 Result result = this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, opts);
486 if (kSuccess != result) {
487 return result;
488 }
489
490 if (dstInfo.dimensions() != this->getInfo().dimensions()) {
491 return gif_error("Scaling not supported.\n", kInvalidScale);
492 }
493
494 // Initialize the swizzler
495 if (fFrameIsSubset) {
496 // Fill the background
497 SkSampler::Fill(dstInfo, dst, dstRowBytes, this->getFillValue(dstInfo),
498 opts.fZeroInitialized);
499 }
500
501 // Iterate over rows of the input
502 for (int y = fFrameRect.top(); y < fFrameRect.bottom(); y++) {
503 if (!this->readRow()) {
504 *rowsDecoded = y;
505 return gif_error("Could not decode line.\n", kIncompleteInput);
506 }
507 void* dstRow = SkTAddOffset<void>(dst, dstRowBytes * this->outputScanline(y));
508 fSwizzler->swizzle(dstRow, fSrcBuffer.get());
509 }
510 return kSuccess;
511 }
512
513 // FIXME: This is similar to the implementation for bmp and png. Can we share more code or
514 // possibly make this non-virtual?
515 uint64_t SkGifCodec::onGetFillValue(const SkImageInfo& dstInfo) const {
516 const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());
517 return get_color_table_fill_value(dstInfo.colorType(), dstInfo.alphaType(), colorPtr,
518 fFillIndex, nullptr);
519 }
520
521 SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
522 const SkCodec::Options& opts, SkPMColor inputColorPtr[], int* inputColorCount) {
523 return this->prepareToDecode(dstInfo, inputColorPtr, inputColorCount, opts);
524 }
525
526 void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsInFrame) {
527 if (fFrameIsSubset) {
528 const int currRow = this->currScanline();
529
530 // The number of rows that remain to be skipped before reaching rows that we
531 // actually must decode into.
532 // This must be at least zero. We also make sure that it is less than or
533 // equal to count, since we will skip at most count rows.
534 *rowsBeforeFrame = SkTMin(count, SkTMax(0, fFrameRect.top() - currRow));
535
536 // Rows left to decode once we reach the start of the frame.
537 const int rowsLeft = count - *rowsBeforeFrame;
538
539 // Count the number of that extend beyond the bottom of the frame. We do not
540 // need to decode into these rows.
541 const int rowsAfterFrame = SkTMax(0, currRow + rowsLeft - fFrameRect.bottom());
542
543 // Set the actual number of source rows that we need to decode.
544 *rowsInFrame = rowsLeft - rowsAfterFrame;
545 } else {
546 *rowsBeforeFrame = 0;
547 *rowsInFrame = count;
548 }
549 }
550
551 int SkGifCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
552 int rowsBeforeFrame;
553 int rowsInFrame;
554 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame);
555
556 if (fFrameIsSubset) {
557 // Fill the requested rows
558 SkImageInfo fillInfo = this->dstInfo().makeWH(this->dstInfo().width(), count);
559 uint64_t fillValue = this->onGetFillValue(this->dstInfo());
560 fSwizzler->fill(fillInfo, dst, rowBytes, fillValue, this->options().fZeroInitialized);
561
562 // Start to write pixels at the start of the image frame
563 dst = SkTAddOffset<void>(dst, rowBytes * rowsBeforeFrame);
564 }
565
566 for (int i = 0; i < rowsInFrame; i++) {
567 if (!this->readRow()) {
568 return i + rowsBeforeFrame;
569 }
570 fSwizzler->swizzle(dst, fSrcBuffer.get());
571 dst = SkTAddOffset<void>(dst, rowBytes);
572 }
573
574 return count;
575 }
576
577 bool SkGifCodec::onSkipScanlines(int count) {
578 int rowsBeforeFrame;
579 int rowsInFrame;
580 this->handleScanlineFrame(count, &rowsBeforeFrame, &rowsInFrame);
581
582 for (int i = 0; i < rowsInFrame; i++) {
583 if (!this->readRow()) {
584 return false;
585 }
586 }
587
588 return true;
589 }
590
591 SkCodec::SkScanlineOrder SkGifCodec::onGetScanlineOrder() const {
592 if (fGif->Image.Interlace) {
593 return kOutOfOrder_SkScanlineOrder;
594 }
595 return kTopDown_SkScanlineOrder;
596 }
597
598 int SkGifCodec::onOutputScanline(int inputScanline) const {
599 if (fGif->Image.Interlace) {
600 if (inputScanline < fFrameRect.top() || inputScanline >= fFrameRect.bottom()) {
601 return inputScanline;
602 }
603 return get_output_row_interlaced(inputScanline - fFrameRect.top(), fFrameRect.height()) +
604 fFrameRect.top();
605 }
606 return inputScanline;
607 }
608