| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkImageDecoder.h" | 9 #include "SkImageDecoder.h" |
| 10 #include "SkImageEncoder.h" | 10 #include "SkImageEncoder.h" |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 int v = cinfo.cur_comp_info[0]->v_samp_factor; | 791 int v = cinfo.cur_comp_info[0]->v_samp_factor; |
| 792 int uvMaxH = uvSize.height() - 1; | 792 int uvMaxH = uvSize.height() - 1; |
| 793 JSAMPROW outputY = static_cast<JSAMPROW>(planes[0]); | 793 JSAMPROW outputY = static_cast<JSAMPROW>(planes[0]); |
| 794 JSAMPROW outputU = static_cast<JSAMPROW>(planes[1]); | 794 JSAMPROW outputU = static_cast<JSAMPROW>(planes[1]); |
| 795 JSAMPROW outputV = static_cast<JSAMPROW>(planes[2]); | 795 JSAMPROW outputV = static_cast<JSAMPROW>(planes[2]); |
| 796 size_t rowBytesY = rowBytes[0]; | 796 size_t rowBytesY = rowBytes[0]; |
| 797 size_t rowBytesU = rowBytes[1]; | 797 size_t rowBytesU = rowBytes[1]; |
| 798 size_t rowBytesV = rowBytes[2]; | 798 size_t rowBytesV = rowBytes[2]; |
| 799 | 799 |
| 800 int yScanlinesToRead = DCTSIZE * v; | 800 int yScanlinesToRead = DCTSIZE * v; |
| 801 SkAutoMalloc lastRowStorage(yWidth * 8); | 801 SkAutoMalloc lastRowStorage(rowBytesY * 4); |
| 802 JSAMPROW yLastRow = (JSAMPROW)lastRowStorage.get(); | 802 JSAMPROW yLastRow = (JSAMPROW)lastRowStorage.get(); |
| 803 JSAMPROW uLastRow = yLastRow + 2 * yWidth; | 803 JSAMPROW uLastRow = yLastRow + rowBytesY; |
| 804 JSAMPROW vLastRow = uLastRow + 2 * yWidth; | 804 JSAMPROW vLastRow = uLastRow + rowBytesY; |
| 805 JSAMPROW dummyRow = vLastRow + 2 * yWidth; | 805 JSAMPROW dummyRow = vLastRow + rowBytesY; |
| 806 | 806 |
| 807 while (cinfo.output_scanline < cinfo.output_height) { | 807 while (cinfo.output_scanline < cinfo.output_height) { |
| 808 // Request 8 or 16 scanlines: returns 0 or more scanlines. | 808 // Request 8 or 16 scanlines: returns 0 or more scanlines. |
| 809 bool hasYLastRow(false), hasUVLastRow(false); | 809 bool hasYLastRow(false), hasUVLastRow(false); |
| 810 // Assign 8 or 16 rows of memory to read the Y channel. | 810 // Assign 8 or 16 rows of memory to read the Y channel. |
| 811 for (int i = 0; i < yScanlinesToRead; ++i) { | 811 for (int i = 0; i < yScanlinesToRead; ++i) { |
| 812 int scanline = (cinfo.output_scanline + i); | 812 int scanline = (cinfo.output_scanline + i); |
| 813 if (scanline < yMaxH) { | 813 if (scanline < yMaxH) { |
| 814 bufferraw2[i] = &outputY[scanline * rowBytesY]; | 814 bufferraw2[i] = &outputY[scanline * rowBytesY]; |
| 815 } else if (scanline == yMaxH) { | 815 } else if (scanline == yMaxH) { |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 return SkImageDecoder::kUnknown_Format; | 1445 return SkImageDecoder::kUnknown_Format; |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { | 1448 static SkImageEncoder* sk_libjpeg_efactory(SkImageEncoder::Type t) { |
| 1449 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; | 1449 return (SkImageEncoder::kJPEG_Type == t) ? SkNEW(SkJPEGImageEncoder) : NULL; |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); | 1452 static SkImageDecoder_DecodeReg gDReg(sk_libjpeg_dfactory); |
| 1453 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); | 1453 static SkImageDecoder_FormatReg gFormatReg(get_format_jpeg); |
| 1454 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); | 1454 static SkImageEncoder_EncodeReg gEReg(sk_libjpeg_efactory); |
| OLD | NEW |