Unwrap loop and remove lots of calls to OpenJPEGImage::data.
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Nov 2018 00:19:24 +0000 (00:19 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 6 Nov 2018 00:19:24 +0000 (00:19 +0000)
src/lib/j2k_image_proxy.cc

index 52b6f34f0c351de8acd5c42a70fff7b02ace8023..1ef00d9465feb924cea3d9df48e87f862319dbb0 100644 (file)
@@ -170,12 +170,15 @@ J2KImageProxy::image (optional<dcp::NoteHandler>, optional<dcp::Size> target_siz
        int const width = _decompressed->size().width;
 
        int p = 0;
+       int* decomp_0 = _decompressed->data (0);
+       int* decomp_1 = _decompressed->data (1);
+       int* decomp_2 = _decompressed->data (2);
        for (int y = 0; y < _decompressed->size().height; ++y) {
                uint16_t* q = (uint16_t *) (image->data()[0] + y * image->stride()[0]);
                for (int x = 0; x < width; ++x) {
-                       for (int c = 0; c < 3; ++c) {
-                               *q++ = _decompressed->data(c)[p] << 4;
-                       }
+                       *q++ = decomp_0[p] << 4;
+                       *q++ = decomp_1[p] << 4;
+                       *q++ = decomp_2[p] << 4;
                        ++p;
                }
        }