blob: d61b0bd3111cd89f62930c3ed9cff2d81b3abea9 [file] [log] [blame]
halcanary@google.comfed30372013-10-04 12:46:45 +00001/*
2 * Copyright 2013 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 "SkBitmap.h"
sugoib227e372014-10-16 13:10:57 -07009#include "SkDecodingImageGenerator.h"
halcanary@google.comfed30372013-10-04 12:46:45 +000010#include "SkForceLinking.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000011#include "SkImageDecoder.h"
sugoib227e372014-10-16 13:10:57 -070012#include "SkPixelRef.h"
halcanary@google.comfed30372013-10-04 12:46:45 +000013#include "SkStream.h"
sugoib227e372014-10-16 13:10:57 -070014#include "SkTemplates.h"
tfarina@chromium.org8f6884a2014-01-24 20:56:26 +000015#include "Test.h"
halcanary@google.comfed30372013-10-04 12:46:45 +000016
17__SK_FORCE_IMAGE_DECODER_LINKING;
18
19#define JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING 0 // do not do this for
20 // normal unit testing.
commit-bot@chromium.orgddf94cf2013-10-12 17:25:17 +000021static unsigned char goodJpegImage[] = {
220xFF, 0xD8, 0xFF, 0xE0, 0x00, 0x10, 0x4A, 0x46,
230x49, 0x46, 0x00, 0x01, 0x01, 0x01, 0x00, 0x8F,
240x00, 0x8F, 0x00, 0x00, 0xFF, 0xDB, 0x00, 0x43,
250x00, 0x05, 0x03, 0x04, 0x04, 0x04, 0x03, 0x05,
260x04, 0x04, 0x04, 0x05, 0x05, 0x05, 0x06, 0x07,
270x0C, 0x08, 0x07, 0x07, 0x07, 0x07, 0x0F, 0x0B,
280x0B, 0x09, 0x0C, 0x11, 0x0F, 0x12, 0x12, 0x11,
290x0F, 0x11, 0x11, 0x13, 0x16, 0x1C, 0x17, 0x13,
300x14, 0x1A, 0x15, 0x11, 0x11, 0x18, 0x21, 0x18,
310x1A, 0x1D, 0x1D, 0x1F, 0x1F, 0x1F, 0x13, 0x17,
320x22, 0x24, 0x22, 0x1E, 0x24, 0x1C, 0x1E, 0x1F,
330x1E, 0xFF, 0xDB, 0x00, 0x43, 0x01, 0x05, 0x05,
340x05, 0x07, 0x06, 0x07, 0x0E, 0x08, 0x08, 0x0E,
350x1E, 0x14, 0x11, 0x14, 0x1E, 0x1E, 0x1E, 0x1E,
360x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
370x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
380x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
390x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
400x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
410x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xFF, 0xC0,
420x00, 0x11, 0x08, 0x00, 0x80, 0x00, 0x80, 0x03,
430x01, 0x22, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
440x01, 0xFF, 0xC4, 0x00, 0x18, 0x00, 0x01, 0x01,
450x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
460x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00,
470x08, 0x06, 0x05, 0xFF, 0xC4, 0x00, 0x4C, 0x10,
480x00, 0x00, 0x01, 0x07, 0x08, 0x05, 0x08, 0x05,
490x0A, 0x03, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00,
500x00, 0x01, 0x02, 0x03, 0x04, 0x06, 0x07, 0x11,
510x05, 0x08, 0x12, 0x13, 0x14, 0x15, 0x38, 0xB4,
520x16, 0x17, 0x21, 0x31, 0x84, 0x18, 0x22, 0x23,
530x24, 0x58, 0xA5, 0xA6, 0xD2, 0x32, 0x51, 0x56,
540x61, 0xD3, 0x28, 0x33, 0x41, 0x48, 0x67, 0x85,
550x86, 0xC3, 0xE4, 0xF0, 0x25, 0x49, 0x55, 0x09,
560x34, 0x35, 0x36, 0x53, 0x68, 0x72, 0x81, 0xA7,
570xE2, 0xFF, 0xC4, 0x00, 0x14, 0x01, 0x01, 0x00,
580x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
590x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
600xC4, 0x00, 0x14, 0x11, 0x01, 0x00, 0x00, 0x00,
610x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
620x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xDA, 0x00,
630x0C, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11,
640x00, 0x3F, 0x00, 0xD9, 0x62, 0x10, 0x80, 0x40,
650x65, 0xED, 0x62, 0x75, 0xC8, 0x7D, 0xFF, 0x00,
660x92, 0x30, 0x33, 0x01, 0x97, 0xB5, 0x89, 0xD7,
670x21, 0xF7, 0xFE, 0x48, 0xC0, 0x0C, 0xC2, 0x10,
680x80, 0x40, 0x66, 0x64, 0xB8, 0x62, 0x64, 0x78,
690xDC, 0xEA, 0x70, 0xCC, 0x06, 0x66, 0x4B, 0x86,
700x26, 0x47, 0x8D, 0xCE, 0xA7, 0x00, 0xCC, 0x21,
710x08, 0x04, 0x31, 0x9F, 0xF2, 0xC5, 0xFD, 0xFF,
720x00, 0x5A, 0x1B, 0x30, 0x63, 0x3F, 0xE5, 0x8B,
730xFB, 0xFE, 0xB4, 0x03, 0x66, 0x01, 0x99, 0x92,
740xE1, 0x89, 0x91, 0xE3, 0x73, 0xA9, 0xC3, 0x30,
750x19, 0x99, 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A,
760x9C, 0x03, 0x30, 0x84, 0x33, 0x33, 0x92, 0x55,
770x7E, 0xCF, 0x29, 0xD8, 0x49, 0x0D, 0xAE, 0xBD,
780xAE, 0xAB, 0xC6, 0xBB, 0xAA, 0x68, 0x92, 0x92,
790x6A, 0xBA, 0xB4, 0xE9, 0x11, 0x7A, 0x7C, 0xD8,
800xC6, 0x84, 0x77, 0x12, 0x11, 0x87, 0xBC, 0x07,
810x67, 0xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA,
820x5E, 0x51, 0x6B, 0x11, 0xFB, 0x76, 0x74, 0xF1,
830xAA, 0x97, 0x94, 0x33, 0x08, 0x00, 0xCE, 0xB1,
840x1F, 0xB7, 0x67, 0x4F, 0x1A, 0xA9, 0x79, 0x41,
850x9B, 0xC4, 0x6C, 0xDE, 0xC2, 0xCB, 0xF6, 0x75,
860x92, 0x84, 0xA0, 0xE5, 0xEC, 0x12, 0xB2, 0x9D,
870xEF, 0x76, 0xC9, 0xBA, 0x50, 0xAA, 0x92, 0xF1,
880xA6, 0xAA, 0x69, 0x12, 0xF4, 0xA4, 0x36, 0x8A,
890x2A, 0xB3, 0x60, 0x77, 0x3A, 0x34, 0xA3, 0x02,
900x6D, 0x1A, 0xC8, 0x0C, 0xBD, 0xAC, 0x4E, 0xB9,
910x0F, 0xBF, 0xF2, 0x46, 0x00, 0xB5, 0x88, 0xFD,
920xBB, 0x3A, 0x78, 0xD5, 0x4B, 0xCA, 0x2D, 0x62,
930x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2, 0x86,
940x61, 0x00, 0x19, 0xD6, 0x23, 0xF6, 0xEC, 0xE9,
950xE3, 0x55, 0x2F, 0x28, 0x33, 0x9A, 0xE3, 0x66,
960xF6, 0x24, 0x97, 0x12, 0xCE, 0xC9, 0xEC, 0xCB,
970x97, 0xD2, 0x49, 0x25, 0x15, 0xAA, 0xCF, 0x29,
980x69, 0x42, 0xAA, 0xA5, 0x7C, 0x56, 0x92, 0x94,
990xEE, 0x88, 0xF3, 0x4A, 0x71, 0xB4, 0x4E, 0x29,
1000xC6, 0xED, 0xDF, 0x46, 0x3B, 0x8A, 0x35, 0x90,
1010x19, 0x99, 0x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A,
1020x9C, 0x01, 0x9B, 0xE4, 0x79, 0x73, 0x93, 0x59,
1030x69, 0xD9, 0x36, 0x65, 0x99, 0x62, 0x34, 0x1E,
1040x56, 0x95, 0xAD, 0x96, 0x75, 0x7B, 0xD6, 0x4F,
1050x94, 0x6F, 0x1A, 0xA3, 0x0C, 0x3C, 0xEE, 0x71,
1060xE6, 0x51, 0x45, 0x56, 0x6D, 0x22, 0xED, 0x29,
1070x29, 0x53, 0xFA, 0x4A, 0x41, 0xE2, 0xFC, 0xBB,
1080x3F, 0x77, 0x28, 0x66, 0x7B, 0x58, 0x9D, 0x72,
1090x1F, 0x7F, 0xE4, 0x8C, 0x0C, 0xC0, 0x31, 0x9F,
1100xCB, 0xB3, 0xF7, 0x72, 0x8F, 0x19, 0xB6, 0x76,
1110x8F, 0x61, 0x8B, 0x99, 0xDA, 0xDA, 0x16, 0x99,
1120xB7, 0xB0, 0x49, 0x2A, 0x74, 0x2D, 0x0C, 0x9D,
1130xD4, 0xAA, 0x92, 0x85, 0x39, 0x40, 0xD2, 0x9B,
1140xD7, 0x0C, 0x3C, 0xA7, 0x16, 0x27, 0x1C, 0x6A,
1150x5D, 0x91, 0xDF, 0x43, 0x70, 0xDC, 0xA2, 0x01,
1160x8C, 0xF5, 0xC1, 0xFE, 0xF1, 0x3F, 0xF3, 0x4F,
1170xFE, 0x07, 0xB5, 0x35, 0xC6, 0x31, 0xEC, 0x4A,
1180xCE, 0x25, 0x9D, 0x94, 0x19, 0x97, 0xD1, 0xA3,
1190x72, 0x4A, 0x5B, 0x55, 0x9E, 0x4D, 0xD1, 0x75,
1200x55, 0xBA, 0x88, 0x2D, 0x25, 0x21, 0xDD, 0x29,
1210xE7, 0x10, 0xE3, 0xA9, 0x1C, 0x43, 0x8E, 0xDB,
1220xBA, 0x94, 0x37, 0x10, 0x6B, 0x21, 0x00, 0x19,
1230xD5, 0xDB, 0xF6, 0xED, 0x17, 0xE0, 0xA5, 0x2F,
1240x30, 0x33, 0x9A, 0xE3, 0x18, 0xF6, 0x25, 0x67,
1250x12, 0xCE, 0xCA, 0x0C, 0xCB, 0xE8, 0xD1, 0xB9,
1260x25, 0x2D, 0xAA, 0xCF, 0x26, 0xE8, 0xBA, 0xAA,
1270xDD, 0x44, 0x16, 0x92, 0x90, 0xEE, 0x94, 0xF3,
1280x88, 0x71, 0xD4, 0x8E, 0x21, 0xC7, 0x6D, 0xDD,
1290x4A, 0x1B, 0x88, 0x35, 0x90, 0x19, 0x99, 0x2E,
1300x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x03, 0x30,
1310x80, 0x04, 0xDB, 0x99, 0x69, 0x09, 0x8B, 0x7E,
1320xCF, 0x8D, 0x99, 0x66, 0x54, 0x6C, 0x12, 0x4A,
1330x9D, 0xC7, 0x67, 0x57, 0xAD, 0x3D, 0x25, 0x0A,
1340x6A, 0xA9, 0x4F, 0x3B, 0x9C, 0x79, 0x4A, 0x71,
1350x62, 0x71, 0xC7, 0x17, 0x69, 0x4B, 0xBF, 0xD4,
1360x1F, 0xC0, 0x43, 0x8C, 0x79, 0xAE, 0xB5, 0x84,
1370x79, 0x57, 0x7E, 0x9A, 0xC8, 0x57, 0xAD, 0xDD,
1380x5B, 0x64, 0xEB, 0x69, 0xD0, 0xD5, 0xD6, 0x50,
1390xA7, 0xF3, 0x47, 0x9B, 0x18, 0xD0, 0x33, 0x7C,
1400x61, 0x0D, 0x9F, 0x48, 0xEC, 0xC0, 0x03, 0x12,
1410xFB, 0x5E, 0xC3, 0x68, 0xCC, 0x2A, 0x34, 0xCC,
1420xCB, 0x83, 0xB7, 0xC9, 0x2B, 0x94, 0xEC, 0xEB,
1430x1A, 0x5E, 0xAA, 0x8E, 0x9D, 0x03, 0xCE, 0x30,
1440xEE, 0x69, 0xE8, 0xC8, 0x71, 0x20, 0x71, 0xA7,
1450x13, 0x69, 0x09, 0xBB, 0xD4, 0x03, 0xD9, 0xE4,
1460xB8, 0xE2, 0x7D, 0x86, 0xEF, 0x65, 0xDF, 0x8C,
1470x2E, 0x4B, 0x8E, 0x27, 0xD8, 0x6E, 0xF6, 0x5D,
1480xF8, 0xC2, 0xD6, 0x23, 0xF6, 0xEC, 0xE9, 0xE3,
1490x55, 0x2F, 0x28, 0xB5, 0x88, 0xFD, 0xBB, 0x3A,
1500x78, 0xD5, 0x4B, 0xCA, 0x02, 0xE4, 0xB8, 0xE2,
1510x7D, 0x86, 0xEF, 0x65, 0xDF, 0x8C, 0x0C, 0xE6,
1520xB8, 0xE1, 0x1D, 0x3B, 0x68, 0xE2, 0x59, 0xD6,
1530x99, 0xA6, 0x65, 0x2D, 0xF2, 0xB2, 0xE5, 0xAA,
1540xD0, 0xB1, 0x78, 0x2D, 0x23, 0xA7, 0x41, 0x69,
1550x29, 0x86, 0xF3, 0x4C, 0x48, 0x43, 0x49, 0x03,
1560x4D, 0x34, 0x9B, 0x08, 0x4D, 0xDE, 0xB0, 0x99,
1570xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA, 0x5E,
1580x50, 0x67, 0x35, 0xC6, 0xCD, 0xEC, 0x49, 0x2E,
1590x25, 0x9D, 0x93, 0xD9, 0x97, 0x2F, 0xA4, 0x92,
1600x4A, 0x2B, 0x55, 0x9E, 0x52, 0xD2, 0x85, 0x55,
1610x4A, 0xF8, 0xAD, 0x25, 0x29, 0xDD, 0x11, 0xE6,
1620x94, 0xE3, 0x68, 0x9C, 0x53, 0x8D, 0xDB, 0xBE,
1630x8C, 0x77, 0x14, 0x04, 0xF1, 0x1C, 0x23, 0xA7,
1640x92, 0x5F, 0xB3, 0xAC, 0x66, 0x64, 0xF6, 0x52,
1650xA6, 0x49, 0x97, 0xAF, 0x7B, 0xC9, 0x5E, 0xF0,
1660x5A, 0x3A, 0xBE, 0xA1, 0x54, 0xD3, 0xD1, 0x73,
1670x8A, 0x90, 0xA7, 0x1B, 0x44, 0xE2, 0x94, 0xBC,
1680xD2, 0x92, 0x3F, 0x4C, 0x48, 0x13, 0x39, 0x2E,
1690x38, 0x9F, 0x61, 0xBB, 0xD9, 0x77, 0xE3, 0x01,
1700x97, 0xF4, 0xF7, 0x1B, 0xB6, 0x51, 0xE7, 0xBB,
1710x76, 0xD5, 0xB5, 0x74, 0xB7, 0x15, 0xCD, 0x7A,
1720x59, 0x15, 0x34, 0x89, 0x02, 0xCD, 0xBA, 0xB9,
1730x02, 0x34, 0x47, 0xF3, 0xD1, 0x18, 0x5A, 0xBA,
1740x14, 0x8C, 0x2E, 0xD2, 0x16, 0x95, 0x28, 0x12,
1750x10, 0x29, 0x46, 0xCC, 0x00, 0x33, 0xC9, 0x71,
1760xC4, 0xFB, 0x0D, 0xDE, 0xCB, 0xBF, 0x18, 0x5C,
1770x97, 0x1C, 0x4F, 0xB0, 0xDD, 0xEC, 0xBB, 0xF1,
1780x83, 0x30, 0x80, 0x0C, 0xF2, 0x5C, 0x71, 0x3E,
1790xC3, 0x77, 0xB2, 0xEF, 0xC6, 0x17, 0x25, 0xC7,
1800x13, 0xEC, 0x37, 0x7B, 0x2E, 0xFC, 0x60, 0xCC,
1810x20, 0x03, 0x3C, 0x97, 0x1C, 0x4F, 0xB0, 0xDD,
1820xEC, 0xBB, 0xF1, 0x81, 0x9C, 0xD7, 0x1C, 0x23,
1830xA7, 0x6D, 0x1C, 0x4B, 0x3A, 0xD3, 0x34, 0xCC,
1840xA5, 0xBE, 0x56, 0x5C, 0xB5, 0x5A, 0x16, 0x2F,
1850x05, 0xA4, 0x74, 0xE8, 0x2D, 0x25, 0x30, 0xDE,
1860x69, 0x89, 0x08, 0x69, 0x20, 0x69, 0xA6, 0x93,
1870x61, 0x09, 0xBB, 0xD6, 0x35, 0x90, 0x19, 0x99,
1880x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x07,
1890x8D, 0x36, 0xE6, 0xA6, 0x42, 0x6D, 0x1F, 0xB3,
1900xE3, 0x69, 0x99, 0x95, 0xEB, 0x7C, 0x92, 0xB9,
1910x71, 0xD9, 0xD6, 0x2A, 0x8F, 0x47, 0x4E, 0x82,
1920xAA, 0x53, 0x0E, 0xE6, 0x9E, 0x42, 0x1C, 0x48,
1930x1C, 0x69, 0xC4, 0xDA, 0x42, 0x6E, 0xF5, 0x07,
1940xF1, 0x08, 0x00, 0xCB, 0x40, 0xF7, 0x1B, 0xBD,
1950x67, 0xB4, 0xEC, 0x53, 0x14, 0xE9, 0x74, 0xAB,
1960x47, 0x2C, 0x96, 0xB5, 0xBD, 0x22, 0x40, 0xA5,
1970xFD, 0xE1, 0x01, 0x12, 0x99, 0xCC, 0x4A, 0x67,
1980xFC, 0xC9, 0xB0, 0xA5, 0xF4, 0x62, 0x58, 0x44,
1990x84, 0x06, 0x73, 0x5C, 0x6C, 0xDE, 0xC4, 0x92,
2000xE2, 0x59, 0xD9, 0x3D, 0x99, 0x72, 0xFA, 0x49,
2010x24, 0xA2, 0xB5, 0x59, 0xE5, 0x2D, 0x28, 0x55,
2020x54, 0xAF, 0x8A, 0xD2, 0x52, 0x9D, 0xD1, 0x1E,
2030x69, 0x4E, 0x36, 0x89, 0xC5, 0x38, 0xDD, 0xBB,
2040xE8, 0xC7, 0x71, 0x42, 0x63, 0xA5, 0xC4, 0xEB,
2050xEF, 0xFB, 0x83, 0x24, 0x78, 0xA6, 0x4B, 0x86,
2060x26, 0x47, 0x8D, 0xCE, 0xA7, 0x01, 0x6B, 0x11,
2070xFB, 0x76, 0x74, 0xF1, 0xAA, 0x97, 0x94, 0x5A,
2080xC4, 0x7E, 0xDD, 0x9D, 0x3C, 0x6A, 0xA5, 0xE5,
2090x0C, 0xC2, 0x00, 0x33, 0xAC, 0x47, 0xED, 0xD9,
2100xD3, 0xC6, 0xAA, 0x5E, 0x50, 0x67, 0x35, 0xC6,
2110xCD, 0xEC, 0x49, 0x2E, 0x25, 0x9D, 0x93, 0xD9,
2120x97, 0x2F, 0xA4, 0x92, 0x4A, 0x2B, 0x55, 0x9E,
2130x52, 0xD2, 0x85, 0x55, 0x4A, 0xF8, 0xAD, 0x25,
2140x29, 0xDD, 0x11, 0xE6, 0x94, 0xE3, 0x68, 0x9C,
2150x53, 0x8D, 0xDB, 0xBE, 0x8C, 0x77, 0x14, 0x6B,
2160x20, 0x33, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
2170x75, 0x38, 0x0C, 0xCD, 0x3E, 0x76, 0x89, 0xBB,
2180x97, 0xF4, 0x3B, 0x4D, 0x5D, 0xD6, 0x86, 0xD4,
2190x5B, 0xAC, 0x9F, 0xC6, 0x90, 0x2F, 0xDA, 0xA9,
2200x59, 0xE9, 0xFC, 0xD1, 0x09, 0x42, 0x8C, 0x0C,
2210xDF, 0xBE, 0x9E, 0xCD, 0xC5, 0x1A, 0x67, 0x58,
2220x8F, 0xDB, 0xB3, 0xA7, 0x8D, 0x54, 0xBC, 0xA3,
2230x8C, 0xFE, 0xD0, 0x76, 0x16, 0xFF, 0x00, 0x76,
2240x0A, 0xAD, 0xAD, 0xE9, 0x66, 0xD1, 0x5A, 0x7D,
2250x52, 0xCF, 0x4E, 0xD5, 0x6A, 0x4E, 0xAC, 0x8B,
2260xD3, 0xA4, 0x4A, 0x14, 0x61, 0x1D, 0xC7, 0x47,
2270x76, 0xCD, 0xE2, 0x7D, 0xAA, 0xAF, 0xD9, 0xDA,
2280xBB, 0x09, 0x5D, 0xB5, 0xD7, 0xB5, 0xEB, 0x77,
2290x54, 0xF5, 0x4D, 0x12, 0x52, 0x43, 0x59, 0x58,
2300x9D, 0x1A, 0x2F, 0x4F, 0x9D, 0x08, 0x53, 0x8E,
2310xE2, 0xC6, 0x10, 0xF7, 0x80, 0xEC, 0xF5, 0x88,
2320xFD, 0xBB, 0x3A, 0x78, 0xD5, 0x4B, 0xCA, 0x2D,
2330x62, 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2,
2340x8C, 0x67, 0xCA, 0x8D, 0xFB, 0x7B, 0x73, 0xDD,
2350x2A, 0x5F, 0x04, 0x5C, 0xA8, 0xDF, 0xB7, 0xB7,
2360x3D, 0xD2, 0xA5, 0xF0, 0x40, 0x6C, 0xCD, 0x62,
2370x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52, 0xF2, 0x8B,
2380x58, 0x8F, 0xDB, 0xB3, 0xA7, 0x8D, 0x54, 0xBC,
2390xA3, 0x33, 0x3B, 0x27, 0xA5, 0x3B, 0x17, 0x95,
2400x78, 0x68, 0x54, 0xBB, 0x7A, 0xDD, 0xD5, 0x56,
2410xBE, 0xA9, 0x25, 0xA1, 0xAB, 0xAC, 0xA7, 0x43,
2420xE7, 0x4C, 0x36, 0x31, 0xA0, 0x7E, 0xE8, 0xC2,
2430x1B, 0x7E, 0x81, 0xD9, 0xFC, 0xBB, 0x3F, 0x77,
2440x28, 0x06, 0x6D, 0x62, 0x3F, 0x6E, 0xCE, 0x9E,
2450x35, 0x52, 0xF2, 0x83, 0x39, 0xAE, 0x36, 0x6F,
2460x62, 0x49, 0x71, 0x2C, 0xEC, 0x9E, 0xCC, 0xB9,
2470x7D, 0x24, 0x92, 0x51, 0x5A, 0xAC, 0xF2, 0x96,
2480x94, 0x2A, 0xAA, 0x57, 0xC5, 0x69, 0x29, 0x4E,
2490xE8, 0x8F, 0x34, 0xA7, 0x1B, 0x44, 0xE2, 0x9C,
2500x6E, 0xDD, 0xF4, 0x63, 0xB8, 0xA3, 0xC5, 0xF9,
2510x76, 0x7E, 0xEE, 0x51, 0xC6, 0x39, 0x2E, 0x56,
2520x3A, 0xB0, 0x92, 0x35, 0x69, 0xFE, 0x53, 0xE9,
2530xAC, 0x1F, 0xE1, 0x7F, 0xEB, 0xA4, 0xAC, 0xF9,
2540xFE, 0x93, 0xE7, 0x2B, 0x3D, 0x2F, 0xFA, 0xD9,
2550x00, 0x1B, 0xFC, 0x42, 0x10, 0x0C, 0x9A, 0xD4,
2560xBE, 0x39, 0x09, 0xCF, 0xBF, 0x67, 0xD5, 0x28,
2570x4A, 0x08, 0x6D, 0xF2, 0xB2, 0xE5, 0xC3, 0x76,
2580xC9, 0xB4, 0x8F, 0x47, 0x6B, 0xA0, 0xAA, 0x42,
2590x25, 0xE9, 0x48, 0x8C, 0xF3, 0x4C, 0xA0, 0x6A,
2600x42, 0x1D, 0xCE, 0x84, 0x61, 0x02, 0x6D, 0xDC,
2610x64, 0xE4, 0xA7, 0x5B, 0xAB, 0x57, 0x61, 0x24,
2620x31, 0x5A, 0x05, 0x7A, 0xDD, 0xD5, 0xDD, 0x6E,
2630xF7, 0xA9, 0xAC, 0xAC, 0x4E, 0x91, 0x2F, 0xA1,
2640x52, 0x74, 0x21, 0x4E, 0x1B, 0xCB, 0x18, 0x47,
2650xDC, 0x34, 0xCC, 0xF6, 0xB0, 0xC4, 0xD7, 0x70,
2660x59, 0xD4, 0x02, 0x99, 0x2E, 0x18, 0x99, 0x1E,
2670x37, 0x3A, 0x9C, 0x00, 0xCF, 0x2E, 0x7F, 0xB2,
2680xEE, 0xFF, 0x00, 0xFD, 0x38, 0xB9, 0x73, 0xFD,
2690x97, 0x77, 0xFF, 0x00, 0xE9, 0xC6, 0xCC, 0x10,
2700x0C, 0x67, 0xCB, 0x9F, 0xEC, 0xBB, 0xBF, 0xFF,
2710x00, 0x4E, 0x38, 0xC7, 0x25, 0x3A, 0xDD, 0x5A,
2720xBB, 0x09, 0x21, 0x8A, 0xD0, 0x2B, 0xD6, 0xEE,
2730xAE, 0xEB, 0x77, 0xBD, 0x4D, 0x65, 0x62, 0x74,
2740x89, 0x7D, 0x0A, 0x93, 0xA1, 0x0A, 0x70, 0xDE,
2750x58, 0xC2, 0x3E, 0xE1, 0xBF, 0xC0, 0xCC, 0xC9,
2760x70, 0xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE0, 0x33,
2770x33, 0xED, 0x9D, 0x6E, 0xB2, 0x9D, 0x84, 0xAE,
2780xC5, 0x68, 0x15, 0xD5, 0x78, 0xD4, 0xF5, 0xBB,
2790xDE, 0xBA, 0xAE, 0xAD, 0x3A, 0x34, 0xBE, 0x85,
2800x49, 0xB1, 0x8D, 0x08, 0x6F, 0x24, 0x23, 0x1F,
2810x70, 0x9F, 0x6C, 0xEB, 0x75, 0x94, 0xEC, 0x25,
2820x76, 0x2B, 0x40, 0xAE, 0xAB, 0xC6, 0xA7, 0xAD,
2830xDE, 0xF5, 0xD5, 0x75, 0x69, 0xD1, 0xA5, 0xF4,
2840x2A, 0x4D, 0x8C, 0x68, 0x43, 0x79, 0x21, 0x18,
2850xFB, 0x86, 0x99, 0x9E, 0xD6, 0x18, 0x9A, 0xEE,
2860x0B, 0x3A, 0x80, 0x53, 0xDA, 0xC3, 0x13, 0x5D,
2870xC1, 0x67, 0x50, 0x00, 0xCC, 0xCE, 0x4A, 0x75,
2880xBA, 0xB5, 0x76, 0x12, 0x43, 0x15, 0xA0, 0x57,
2890xAD, 0xDD, 0x5D, 0xD6, 0xEF, 0x7A, 0x9A, 0xCA,
2900xC4, 0xE9, 0x12, 0xFA, 0x15, 0x27, 0x42, 0x14,
2910xE1, 0xBC, 0xB1, 0x84, 0x7D, 0xC3, 0xB3, 0xE5,
2920xCF, 0xF6, 0x5D, 0xDF, 0xFF, 0x00, 0xA7, 0x0C,
2930xD3, 0x25, 0xC3, 0x13, 0x23, 0xC6, 0xE7, 0x53,
2940x86, 0x60, 0x18, 0x01, 0x92, 0x9D, 0x6D, 0xC0,
2950xF3, 0xDB, 0x76, 0xD7, 0x40, 0xAD, 0x3A, 0x55,
2960x60, 0xEA, 0x97, 0xBD, 0x0B, 0x2D, 0x95, 0x01,
2970x51, 0x7A, 0x75, 0x25, 0xA7, 0x4A, 0x31, 0xDC,
2980x6C, 0x37, 0x6D, 0xDE, 0x3B, 0x3E, 0x5C, 0xFF,
2990x00, 0x65, 0xDD, 0xFF, 0x00, 0xFA, 0x70, 0xCC,
3000xE9, 0x71, 0x3A, 0xFB, 0xFE, 0xE0, 0xC9, 0x1E,
3010x19, 0x80, 0x63, 0x3E, 0x5C, 0xFF, 0x00, 0x65,
3020xDD, 0xFF, 0x00, 0xFA, 0x71, 0xC6, 0x39, 0x29,
3030xD6, 0xEA, 0xD5, 0xD8, 0x49, 0x0C, 0x56, 0x81,
3040x5E, 0xB7, 0x75, 0x77, 0x5B, 0xBD, 0xEA, 0x6B,
3050x2B, 0x13, 0xA4, 0x4B, 0xE8, 0x54, 0x9D, 0x08,
3060x53, 0x86, 0xF2, 0xC6, 0x11, 0xF7, 0x0D, 0xFE,
3070x06, 0x66, 0x4B, 0x86, 0x26, 0x47, 0x8D, 0xCE,
3080xA7, 0x00, 0xCC, 0x21, 0x08, 0x00, 0xCC, 0xF6,
3090xB0, 0xC4, 0xD7, 0x70, 0x59, 0xD4, 0x02, 0x99,
3100x2E, 0x18, 0x99, 0x1E, 0x37, 0x3A, 0x9C, 0x53,
3110xDA, 0xC3, 0x13, 0x5D, 0xC1, 0x67, 0x50, 0x0A,
3120x64, 0xB8, 0x62, 0x64, 0x78, 0xDC, 0xEA, 0x70,
3130x0C, 0xC2, 0x10, 0x80, 0x40, 0x66, 0x64, 0xB8,
3140x62, 0x64, 0x78, 0xDC, 0xEA, 0x70, 0xCC, 0x06,
3150x66, 0x4B, 0x86, 0x26, 0x47, 0x8D, 0xCE, 0xA7,
3160x01, 0x4F, 0x6B, 0x0C, 0x4D, 0x77, 0x05, 0x9D,
3170x40, 0x29, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3,
3180xA8, 0x05, 0x3D, 0xAC, 0x31, 0x35, 0xDC, 0x16,
3190x75, 0x00, 0xA7, 0xB5, 0x86, 0x26, 0xBB, 0x82,
3200xCE, 0xA0, 0x01, 0x4C, 0x97, 0x0C, 0x4C, 0x8F,
3210x1B, 0x9D, 0x4E, 0x19, 0x86, 0x4D, 0x9A, 0xE3,
3220xFB, 0x74, 0xEC, 0x5B, 0x89, 0x67, 0x59, 0x96,
3230x99, 0xAB, 0xB0, 0x4A, 0xCA, 0x76, 0xAB, 0x42,
3240xBD, 0xDE, 0xB4, 0x92, 0x85, 0x35, 0xA4, 0xA7,
3250x9B, 0xCE, 0x31, 0x19, 0x4D, 0x2C, 0x4D, 0x38,
3260xD2, 0xEC, 0x29, 0x77, 0xFA, 0xC2, 0x67, 0x2A,
3270x37, 0x13, 0xED, 0xCF, 0x74, 0xAE, 0xFC, 0x10,
3280x03, 0x33, 0x80, 0xFA, 0xCE, 0xFE, 0x13, 0xFC,
3290xB0, 0xCD, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
3300x75, 0x38, 0x00, 0x79, 0x2D, 0x4C, 0x84, 0xDA,
3310x33, 0x13, 0x91, 0x69, 0x99, 0x95, 0xEB, 0x7C,
3320x92, 0xB9, 0xA2, 0xF6, 0x75, 0x8A, 0xA3, 0xD1,
3330xD3, 0xA0, 0x79, 0xA6, 0x1D, 0xCD, 0x3C, 0x84,
3340x38, 0x90, 0x38, 0xD3, 0x89, 0xB4, 0x84, 0xDD,
3350xEA, 0x0F, 0xF3, 0x25, 0xC3, 0x13, 0x23, 0xC6,
3360xE7, 0x53, 0x80, 0x66, 0x03, 0x33, 0x25, 0xC3,
3370x13, 0x23, 0xC6, 0xE7, 0x53, 0x86, 0x60, 0x33,
3380x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38,
3390x06, 0x61, 0x08, 0x40, 0x06, 0x67, 0xB5, 0x86,
3400x26, 0xBB, 0x82, 0xCE, 0xA0, 0x14, 0xC9, 0x70,
3410xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE2, 0x9E, 0xD6,
3420x18, 0x9A, 0xEE, 0x0B, 0x3A, 0x80, 0x53, 0x25,
3430xC3, 0x13, 0x23, 0xC6, 0xE7, 0x53, 0x80, 0x66,
3440x10, 0x84, 0x02, 0x03, 0x33, 0x25, 0xC3, 0x13,
3450x23, 0xC6, 0xE7, 0x53, 0x86, 0x60, 0x33, 0x32,
3460x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38, 0x0A,
3470x7B, 0x58, 0x62, 0x6B, 0xB8, 0x2C, 0xEA, 0x01,
3480x4F, 0x6B, 0x0C, 0x4D, 0x77, 0x05, 0x9D, 0x40,
3490x29, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3, 0xA8,
3500x05, 0x3D, 0xAC, 0x31, 0x35, 0xDC, 0x16, 0x75,
3510x00, 0x06, 0x61, 0x08, 0x40, 0x31, 0x9C, 0xEB,
3520x65, 0x86, 0xEE, 0x5F, 0xD7, 0x2C, 0x93, 0xA6,
3530x36, 0x66, 0x4D, 0x95, 0xB8, 0xFF, 0x00, 0x82,
3540xDD, 0x88, 0x0F, 0xB5, 0x5A, 0xAA, 0x4E, 0xF9,
3550xF8, 0x11, 0x21, 0x94, 0x52, 0x12, 0x9E, 0xF3,
3560xA3, 0xBB, 0x61, 0x07, 0xB5, 0x35, 0xC6, 0x31,
3570xEC, 0x4A, 0xCE, 0x25, 0x9D, 0x94, 0x19, 0x97,
3580xD1, 0xA3, 0x72, 0x4A, 0x5B, 0x55, 0x9E, 0x4D,
3590xD1, 0x75, 0x55, 0xBA, 0x88, 0x2D, 0x25, 0x21,
3600xDD, 0x29, 0xE7, 0x10, 0xE3, 0xA9, 0x1C, 0x43,
3610x8E, 0xDB, 0xBA, 0x94, 0x37, 0x10, 0x78, 0xB3,
3620x80, 0xFA, 0xCE, 0xFE, 0x13, 0xFC, 0xB0, 0xCD,
3630x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E, 0x75, 0x38,
3640x0B, 0x57, 0x6F, 0xDB, 0xB4, 0x5F, 0x82, 0x94,
3650xBC, 0xC0, 0xCE, 0x6B, 0x8C, 0x63, 0xD8, 0x95,
3660x9C, 0x4B, 0x3B, 0x28, 0x33, 0x2F, 0xA3, 0x46,
3670xE4, 0x94, 0xB6, 0xAB, 0x3C, 0x9B, 0xA2, 0xEA,
3680xAB, 0x75, 0x10, 0x5A, 0x4A, 0x43, 0xBA, 0x53,
3690xCE, 0x21, 0xC7, 0x52, 0x38, 0x87, 0x1D, 0xB7,
3700x75, 0x28, 0x6E, 0x20, 0xD6, 0x40, 0x66, 0x64,
3710xB8, 0x62, 0x64, 0x78, 0xDC, 0xEA, 0x70, 0x16,
3720xB1, 0x1F, 0xB7, 0x67, 0x4F, 0x1A, 0xA9, 0x79,
3730x45, 0xAC, 0x47, 0xED, 0xD9, 0xD3, 0xC6, 0xAA,
3740x5E, 0x50, 0xCC, 0x20, 0x19, 0x36, 0x74, 0x6D,
3750x9B, 0xD8, 0x95, 0x9C, 0x4B, 0x45, 0x27, 0xB4,
3760xCE, 0x5F, 0x46, 0xE4, 0x94, 0xB6, 0x5B, 0x44,
3770xA5, 0xA5, 0x0A, 0xAB, 0x75, 0x10, 0x5A, 0x44,
3780x53, 0x7A, 0x23, 0x0D, 0x21, 0xC7, 0x52, 0x38,
3790x86, 0x9B, 0xB3, 0x75, 0x28, 0xEE, 0x20, 0xA6,
3800xB8, 0xD9, 0xBD, 0x89, 0x25, 0xC4, 0xB3, 0xB2,
3810x7B, 0x32, 0xE5, 0xF4, 0x92, 0x49, 0x45, 0x6A,
3820xB3, 0xCA, 0x5A, 0x50, 0xAA, 0xA9, 0x5F, 0x15,
3830xA4, 0xA5, 0x3B, 0xA2, 0x3C, 0xD2, 0x9C, 0x6D,
3840x13, 0x8A, 0x71, 0xBB, 0x77, 0xD1, 0x8E, 0xE2,
3850x84, 0xC9, 0xED, 0x61, 0x89, 0xAE, 0xE0, 0xB3,
3860xA8, 0x05, 0x32, 0x5C, 0x31, 0x32, 0x3C, 0x6E,
3870x75, 0x38, 0x0B, 0x58, 0x8F, 0xDB, 0xB3, 0xA7,
3880x8D, 0x54, 0xBC, 0xA2, 0xD6, 0x23, 0xF6, 0xEC,
3890xE9, 0xE3, 0x55, 0x2F, 0x28, 0x66, 0x10, 0x01,
3900x9D, 0x62, 0x3F, 0x6E, 0xCE, 0x9E, 0x35, 0x52,
3910xF2, 0x8F, 0x6A, 0x6B, 0x8C, 0xB4, 0xBA, 0xC5,
3920xB8, 0x96, 0x75, 0x99, 0x69, 0x94, 0x6C, 0x12,
3930xB2, 0x9D, 0xAA, 0xD0, 0xAF, 0x5A, 0x62, 0x4A,
3940x14, 0xD6, 0x92, 0x9E, 0x6F, 0x38, 0xC2, 0x94,
3950xD2, 0xC4, 0xD3, 0x8D, 0x2E, 0xC2, 0x97, 0x7F,
3960xAC, 0x26, 0x08, 0x00, 0xCC, 0xF6, 0xB0, 0xC4,
3970xD7, 0x70, 0x59, 0xD4, 0x02, 0x9E, 0xD6, 0x18,
3980x9A, 0xEE, 0x0B, 0x3A, 0x80, 0x53, 0xDA, 0xC3,
3990x13, 0x5D, 0xC1, 0x67, 0x50, 0x0A, 0x7B, 0x58,
4000x62, 0x6B, 0xB8, 0x2C, 0xEA, 0x00, 0x0C, 0xC2,
4010x10, 0x80, 0x63, 0x39, 0xC0, 0x7D, 0x67, 0x7F,
4020x09, 0xFE, 0x58, 0x66, 0x99, 0x2E, 0x18, 0x99,
4030x1E, 0x37, 0x3A, 0x9C, 0x0C, 0xCE, 0x03, 0xEB,
4040x3B, 0xF8, 0x4F, 0xF2, 0xC3, 0x34, 0xC9, 0x70,
4050xC4, 0xC8, 0xF1, 0xB9, 0xD4, 0xE0, 0x19, 0x80,
4060xCC, 0xC9, 0x70, 0xC4, 0xC8, 0xF1, 0xB9, 0xD4,
4070xE1, 0x98, 0x0C, 0xCC, 0x97, 0x0C, 0x4C, 0x8F,
4080x1B, 0x9D, 0x4E, 0x03, 0xFF, 0xD9};
409static const int goodJpegImageWidth = 128;
410static const int goodJpegImageHeight = 128;
halcanary@google.comfed30372013-10-04 12:46:45 +0000411
412// https://code.google.com/p/android/issues/detail?id=42382
413// https://code.google.com/p/android/issues/detail?id=9064
414// https://code.google.com/p/skia/issues/detail?id=1649
415
416/**
417 This test will test the ability of the SkImageDecoder to deal with
418 Jpeg files which have been mangled somehow. We want to display as
419 much of the jpeg as possible.
420*/
tfarina@chromium.orge4fafb12013-12-12 21:11:12 +0000421DEF_TEST(Jpeg, reporter) {
halcanary@google.comfed30372013-10-04 12:46:45 +0000422 size_t len = sizeof(goodJpegImage) / 2;
423 // I am explicitly not putting the entire image into the
424 // DecodeMemory. This simulates a network error.
425
426 SkBitmap bm8888;
427 bool imageDecodeSuccess = SkImageDecoder::DecodeMemory(
428 static_cast<void *>(goodJpegImage), len, &bm8888);
429 REPORTER_ASSERT(reporter, imageDecodeSuccess);
430 REPORTER_ASSERT(reporter, bm8888.width() == goodJpegImageWidth);
431 REPORTER_ASSERT(reporter, bm8888.height() == goodJpegImageHeight);
432 REPORTER_ASSERT(reporter, !(bm8888.empty()));
433
434 // Pick a few pixels and verify that their colors match the colors
435 // we expect (given the original image).
436 REPORTER_ASSERT(reporter, bm8888.getColor(7, 9) == 0xffffffff);
437 REPORTER_ASSERT(reporter, bm8888.getColor(28, 3) == 0xff000000);
438 REPORTER_ASSERT(reporter, bm8888.getColor(27, 34) == 0xffffffff);
439 REPORTER_ASSERT(reporter, bm8888.getColor(71, 18) == 0xff000000);
440
caryclark936b7342014-07-11 12:14:51 -0700441#ifdef SK_BUILD_FOR_IOS // the iOS jpeg decoder fills to gray
442 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == 0xff808080
443 || bm8888.getColor(127, 127) == SK_ColorWHITE);
444#else
halcanary@google.comfed30372013-10-04 12:46:45 +0000445 // This is the fill color
446 REPORTER_ASSERT(reporter, bm8888.getColor(127, 127) == SK_ColorWHITE);
caryclark936b7342014-07-11 12:14:51 -0700447#endif
halcanary@google.comfed30372013-10-04 12:46:45 +0000448
449 #if JPEG_TEST_WRITE_TO_FILE_FOR_DEBUGGING
450 // Check to see that the resulting bitmap is nice
451 bool writeSuccess = (!(bm8888.empty())) && SkImageEncoder::EncodeFile(
452 "HalfOfAJpeg.png", bm8888, SkImageEncoder::kPNG_Type, 100);
453 SkASSERT(writeSuccess);
454 #endif
455}
sugoib227e372014-10-16 13:10:57 -0700456
457DEF_TEST(Jpeg_YUV, reporter) {
458 size_t len = sizeof(goodJpegImage);
halcanary385fe4d2015-08-26 13:07:48 -0700459 SkMemoryStream* stream = new SkMemoryStream(goodJpegImage, len);
sugoib227e372014-10-16 13:10:57 -0700460 SkDecodingImageGenerator::Options opts;
reed74bd9532015-09-14 08:52:12 -0700461 SkAutoTDelete<SkImageGenerator> gen(SkDecodingImageGenerator::Create(stream, opts));
462 REPORTER_ASSERT(reporter, gen);
463 if (!gen) {
sugoib227e372014-10-16 13:10:57 -0700464 return;
465 }
466
sugoib227e372014-10-16 13:10:57 -0700467 SkISize yuvSizes[3];
reed74bd9532015-09-14 08:52:12 -0700468 bool sizesComputed = gen->getYUV8Planes(yuvSizes, nullptr, nullptr, nullptr);
sugoib227e372014-10-16 13:10:57 -0700469 REPORTER_ASSERT(reporter, sizesComputed);
sugoib227e372014-10-16 13:10:57 -0700470 if (!sizesComputed) {
471 return;
472 }
473
474 // Allocate the memory for YUV
475 size_t totalSize(0);
476 size_t sizes[3], rowBytes[3];
477 const int32_t expected_sizes[] = {128, 64, 64};
478 for (int i = 0; i < 3; ++i) {
479 rowBytes[i] = yuvSizes[i].fWidth;
480 totalSize += sizes[i] = rowBytes[i] * yuvSizes[i].fHeight;
481 REPORTER_ASSERT(reporter, rowBytes[i] == (size_t)expected_sizes[i]);
482 REPORTER_ASSERT(reporter, yuvSizes[i].fWidth == expected_sizes[i]);
483 REPORTER_ASSERT(reporter, yuvSizes[i].fHeight == expected_sizes[i]);
484 }
485 SkAutoMalloc storage(totalSize);
486 void* planes[3];
487 planes[0] = storage.get();
488 planes[1] = (uint8_t*)planes[0] + sizes[0];
489 planes[2] = (uint8_t*)planes[1] + sizes[1];
490
491 // Get the YUV planes
reed74bd9532015-09-14 08:52:12 -0700492 REPORTER_ASSERT(reporter, gen->getYUV8Planes(yuvSizes, planes, rowBytes, nullptr));
sugoib227e372014-10-16 13:10:57 -0700493}