Opened 15 years ago
Closed 15 years ago
#3167 closed defect (fixed)
mapserver defective JPEG code
Reported by: | warmerdam | Owned by: | sdlime |
---|---|---|---|
Priority: | normal | Milestone: | 5.6 release |
Component: | MapServer C Library | Version: | unspecified |
Severity: | normal | Keywords: | jpeg |
Cc: |
Description
Hello Frank
While updating packages for the new libjpeg version 7 I got hint from Debian maintainer about defective JPEG code in your mapserver package, version 5.4.2.
In file mapraster.c, function drawJPEG, the following code sequence
/* muck with scaling */ if(MS_MIN(skipx, skipy) >= 8) cinfo.scale_denom = 8; else if(MS_MIN(skipx, skipy) >= 4) cinfo.scale_denom = 4; else if(MS_MIN(skipx, skipy) >= 2) cinfo.scale_denom = 2;
should be replaced with
/* muck with scaling */ cinfo.scale_num = 1; if(MS_MIN(skipx, skipy) >= 8) cinfo.scale_denom = 8; else if(MS_MIN(skipx, skipy) >= 4) cinfo.scale_denom = 4; else if(MS_MIN(skipx, skipy) >= 2) cinfo.scale_denom = 2;
i.e. you just add the statement cinfo.scale_num = 1; there.
This addition will work with older and newer versions of the library.
The implicit assumption of the given code that cinfo.scale_num is initialized with 1 by the JPEG library is no longer true for versions 7 and later! Version 7 initializes this field (and the other) with 8, and version 8 and later will initialize the fields with the (variable from 1 to 16) block size of the given JPEG file. (Note that the default resulting scaling factor remains 1 in any case.)
The usual recommendation for versions up to 6 has always been that "scale_num" and "scale_denom" be set *simultaneously* by the calling application. Applications following this recommendation will not suffer an incompatibility with newer JPEG library versions. Newer applications (written for JPEG library versions 7 and later) MAY choose to set only one of both fields, because the initialization defaults are now depending on the input file and are specified as mentioned above (see also http://jpegclub.org/djpeg/).
The given correction code simply retains the same behaviour with new JPEG library versions as with old JPEG library versions. The code may later be revised to utilize the more flexible scaling choices of v7 and later, but there is no need to do this now.
IJG JPEG 7 is available at the usual place: http://www.ijg.org .
Regards Guido Vollbeding Organizer Independent JPEG Group
Change History (1)
comment:1 by , 15 years ago
Milestone: | → 5.6 release |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Corrected in trunk (r9440), will appear in beta4.
Note that this code is now virtual never used and so it is assumed not to be a major problem.