• Robert Sprowson's avatar
    Paper and fill some JPEG cracks. · 06d6b99e
    Robert Sprowson authored
    The exit_c function was repeatedly being called with the line number argument and error code the wrong way round and since only bits 0-2 of the error code are inspected on exit any fatal exits from the ported JPEG library code would either report the wrong error or fail silently (depending on the line number) - example a 12 bits per sample JPEG would be rendered without fault into a screen full of random memory garbage.
    Assembling/compiling with the 'jpeg' switch off didn't work, fixed, and also now zeros out the SWI decode values in the module header.
    Moved include of 'yuvtabs.s' into the colour conversion code.
    Deleted panic_exit, it did nothing useful but trace a value then exit, so it now just calls exit() like everyone else.
    Removed excess call to find_image_dims(), this was needed just to get the workspace requirements when the JPEG had already been sized up by asm_find_image_dims() earlier. Side effect of removing the pilot JPEG code earlier is that this call can now only get to the JPEG code from a JPEG_ SWI. Changed to just pass the workspace requirements into 'c.PutScaled' and save a duplicate scan.
    Fatal exits from the assembler huffman decoder now report a sensible error.
    Trimmed out all the JPEG assessment code from 'c.PutScaled' and moved it into 'c.rojpeg' so the put scaled is only concerned with putting things scaled.
    Sanitised the #includes a bit.
    Fixed on last check of wp->save_mode looking at the wrong bits for the mode number.
    Resolved all the warning in the genhdr/genyuvtabs/genpalette utilities by casting a bit harder.[A[B
    Added new more descriptive error messages to the messages file (not currently used), and made the 'not supported by' ones consistent so the tokeniser might crunch the file a bit more.
    In looks_like_jpeg() changed a bitwise to logical or.
    Fixed longstanding problem of not being able to render JPEGs at a scale of less than 1/6 in any greyscale mode, because, err, there was no code to do it - only the colour case was checked for. Implemented for 8bpp grey and 32bpp grey (which gets dithered for other lower modes) by just converting the luma channel into an equally weighted RGB value or replicating it for 256 greys.
    Tested in all 8 colour depths on a Risc PC using sampling ratios of 1x1; 2x1; 1x2; 2x2 of the IJG test image scaled in !Draw by 0.16.
    
    Version 1.32. Tagged as 'SprExtend-1_32'
    06d6b99e
CFSI-JPEG 6.6 KB