DFJPEGTurbo 0.2.1

DFJPEGTurbo 0.2.1

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Aug 2015

Maintained by kean.



  • By
  • Alexander Grebenyuk

Objective-C libjpeg-turbo wrapper (JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems). DFJPEGTurbo uses libjpeg-turbo version 1.4.1, which now includes arm64 support.

DFJPEGTurbo supports decompression of both baseline and progressive JPEG.

Requirements

  • iOS 6.0

Examples

Decompressing JPEG

NSData *jpegData;
UIImage *image = [DFJPEGTurboImageDecoder imageWithData:data];

Decompressing JPEG with one of the libjpeg-turbo scale factors

NSData *jpegData;
// Scale must be implemented by libjpeg-turbo which supports only several scaling factors (1/1, 1/2, 1/4 etc).
DFJPEGScale scale = DFJPEGScaleMake(1, 2); // 0.5 scale
UIImage *image = [DFJPEGTurboImageDecoder imageWithData:jpegData orientation:UIImageOrientationDown scale:scale];

Benchmark (Baseline JPEG)

Benchmark on older ARM-based systems (iPhone 4S, iPhone 5C) shows that libjpeg-turbo provides a very noticable performance boost over native CGContextDrawImage. However, libjpeg-turbo underperforms on newer systems (iPhone 6). For benchmark implementation see Demo/DFJPEGTurboBenchmark in a project folder.

iPhone 6 (Apple A8)

Input Image CGContextDrawImage libjpeg-turbo
1024x768, 0.3 compression quality 10.51 ms 9.75 ms
1024x768, 0.5 compression quality 10.56 ms 10.15 ms
1024x768, 0.7 compression quality 10.14 ms 11.61 ms
1024x768, 0.9 compression quality 10.13 ms 12.44 ms
2048x1536, 0.3 compression quality 41.60 ms 36.98 ms
2048x1536, 0.5 compression quality 33.46 ms 40.56 ms
2048x1536, 0.7 compression quality 33.85 ms 45.53 ms
2048x1536, 0.9 compression quality 34.79 ms 52.60 ms

iPhone 5C (Apple A6)

Input Image CGContextDrawImage DFJPEGTurbo
1024x768, 0.3 compression quality 42.47 ms 22.26 ms
1024x768, 0.5 compression quality 40.75 ms 23.28 ms
1024x768, 0.7 compression quality 40.51 ms 26.11 ms
1024x768, 0.9 compression quality 39.82 ms 29.77 ms
2048x1536, 0.3 compression quality 130.72 ms 81.95 ms
2048x1536, 0.5 compression quality 129.83 ms 86.50 ms
2048x1536, 0.7 compression quality 130.42 ms 98.17 ms
2048x1536, 0.9 compression quality 130.03 ms 106.18 ms

Contacts

License

DFJPEGTurbo is available under the MIT license. See the LICENSE file for more info.