[Qt] use libjpeg-turbo rather than Qt's built-in JPEG decoding
libjpeg-turbo is typically 2-4x faster than the built-in decoding.
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
01b06c2301
commit
e5c829b38c
@@ -34,6 +34,7 @@
|
||||
'sources': [
|
||||
'../default/asset_file_source.cpp',
|
||||
'../default/default_file_source.cpp',
|
||||
'../default/jpeg_reader.cpp',
|
||||
'../default/log_stderr.cpp',
|
||||
'../default/mbgl/storage/offline.cpp',
|
||||
'../default/mbgl/storage/offline_database.cpp',
|
||||
@@ -65,6 +66,7 @@
|
||||
'variables': {
|
||||
'cflags': [
|
||||
'<@(boost_cflags)',
|
||||
'<@(libjpeg-turbo_cflags)',
|
||||
'<@(nunicode_cflags)',
|
||||
'<@(opengl_cflags)',
|
||||
'<@(qt_cflags)',
|
||||
@@ -76,6 +78,7 @@
|
||||
'-fPIC',
|
||||
],
|
||||
'ldflags': [
|
||||
'<@(libjpeg-turbo_ldflags)',
|
||||
'<@(nunicode_ldflags)',
|
||||
'<@(opengl_ldflags)',
|
||||
'<@(qt_ldflags)',
|
||||
@@ -86,6 +89,7 @@
|
||||
'libraries': [
|
||||
'<@(nunicode_static_libs)',
|
||||
'<@(sqlite_static_libs)',
|
||||
'<@(libjpeg-turbo_static_libs)',
|
||||
'<@(webp_static_libs)',
|
||||
'<@(zlib_static_libs)',
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
BOOST_VERSION=1.59.0
|
||||
GEOJSONVT_VERSION=4.1.2
|
||||
GTEST_VERSION=1.7.0
|
||||
LIBJPEG_TURBO_VERSION=1.4.2
|
||||
NUNICODE_VERSION=1.6
|
||||
PIXELMATCH_VERSION=0.9.0
|
||||
RAPIDJSON_VERSION=1.0.2
|
||||
|
||||
@@ -19,6 +19,7 @@ std::string encodePNG(const PremultipliedImage& pre) {
|
||||
return std::string(array.constData(), array.size());
|
||||
}
|
||||
|
||||
PremultipliedImage decodeJPEG(const uint8_t*, size_t);
|
||||
PremultipliedImage decodeWebP(const uint8_t*, size_t);
|
||||
|
||||
PremultipliedImage decodeImage(const std::string& string) {
|
||||
@@ -34,6 +35,14 @@ PremultipliedImage decodeImage(const std::string& string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Use libjpeg-turbo rather than the built-in version of libjpeg.
|
||||
if (size >= 2) {
|
||||
uint16_t magic = ((data[0] << 8) | data[1]) & 0xffff;
|
||||
if (magic == 0xFFD8) {
|
||||
return decodeJPEG(data, size);
|
||||
}
|
||||
}
|
||||
|
||||
QImage image =
|
||||
QImage::fromData(data, size)
|
||||
.rgbSwapped()
|
||||
|
||||
Reference in New Issue
Block a user