Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 1683283002: More efficient Jpeg skipScanlines for older versions of libjpeg-turbo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index aefe264f1ad9b1963e0359da4d51801b35b3d734..50186e721310a6d33253fead2899825211c69126 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -438,27 +438,27 @@ int SkJpegCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) {
return count;
}
-#ifndef TURBO_HAS_SKIP
-// TODO (msarett): Avoid reallocating the memory buffer on each call to skip.
-static uint32_t jpeg_skip_scanlines(jpeg_decompress_struct* dinfo, int count) {
- SkAutoTMalloc<uint8_t> storage(get_row_bytes(dinfo));
- uint8_t* storagePtr = storage.get();
- for (int y = 0; y < count; y++) {
- if (1 != jpeg_read_scanlines(dinfo, &storagePtr, 1)) {
- return y;
- }
- }
- return count;
-}
-#endif
-
bool SkJpegCodec::onSkipScanlines(int count) {
// Set the jump location for libjpeg errors
if (setjmp(fDecoderMgr->getJmpBuf())) {
return fDecoderMgr->returnFalse("setjmp");
}
+#ifdef TURBO_HAS_SKIP
return (uint32_t) count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
+#else
+ if (!fSrcRow) {
+ fStorage.reset(get_row_bytes(fDecoderMgr->dinfo()));
+ fSrcRow = fStorage.get();
+ }
+
+ for (int y = 0; y < count; y++) {
+ if (1 != jpeg_read_scanlines(fDecoderMgr->dinfo(), &fSrcRow, 1)) {
+ return false;
+ }
+ }
+ return true;
+#endif
}
static bool is_yuv_supported(jpeg_decompress_struct* dinfo) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698