Fix expensive decompression in JPEG GetImageInfo
The current implementation of GetImageInfo starts a libjpeg decompression pass over input images. Certain images (e.g., progressive JPEG) trigger a full image decompression, resulting in a performance degradation. This commit switches to an equivalent but cheaper libjpeg call for evaluating image dimensions.
This commit is contained in:
parent
d6e0181f1d
commit
c5a6556942
@ -577,7 +577,7 @@ bool GetImageInfo(const void* srcdata, int datasize, int* width, int* height,
|
||||
SetSrc(&cinfo, srcdata, datasize, false);
|
||||
|
||||
jpeg_read_header(&cinfo, TRUE);
|
||||
jpeg_start_decompress(&cinfo); // required to transfer image size to cinfo
|
||||
jpeg_calc_output_dimensions(&cinfo);
|
||||
if (width) *width = cinfo.output_width;
|
||||
if (height) *height = cinfo.output_height;
|
||||
if (components) *components = cinfo.output_components;
|
||||
|
Loading…
x
Reference in New Issue
Block a user