[PATCH] Progressive JPEGs

Lubos Lunak l.lunak at suse.cz
Fri Apr 1 15:01:14 BST 2005


 Hello,

 currently progressive JPEGs (created using e.g. jpegtran -progressive) more 
or less don't work. Meaning they are handled like normal non-progressive. 
Attached progressive.patch should fix that. The problems are:

- in state 'decompressStarted' the next state is usually selected to be 
'consumeInput', which loops calling jpeg_consume_input() without checking for 
ends of scans (or whatever the exact name for one progressive pass is). 
That's fixed by second snippet of the patch (courtesy of Maksim, more or 
less).

- at the beginning of state 'prepareOutputScan' the timer is reset, which 
means that if one scan takes slightly less than those 2 seconds, 
consumer->changed() is not called until end. Third snippet of the patch.

- The rest of the patch is splitting change_rect into two, because not 
resetting the timer at the beginning of each scan means it change_rect could 
be assigned a union of a rect from the top and the bottom, resulting in a 
rect equal to the whole image size. I.e. this is an optimizations.

 There's one more issue that's not actually a problem for KHTML, because 
QMovie doesn't hesitate to call decode() again even after it returns 0 
(=done), but this has caused me some trouble in Gwenview. See attached 
repeat.patch . I think the comment in the code already makes it clear 
something like that should be there. The problem is roughly that decode() 
puts the whole input data into its buffer, and finishes decoding one scan. 
Then instead of processing the data further it simply returns. If there's no 
additional data to process next decode() with be called with length == 0, 
which will set consumed to 0, one more scan will be done, and then there's 
again 'return consumed;', with 0 meaning 'done'.

 Ok to commit?

PS: A good way of faking a slow link turned out to be copying a large JPEG to 
a floppy. When mounted using subfs it even takes care of flushing the caches.

-- 
Lubos Lunak
KDE developer
---------------------------------------------------------------------
SuSE CR, s.r.o.  e-mail: l.lunak at suse.cz , l.lunak at kde.org
Drahobejlova 27  tel: +420 2 9654 2373
190 00 Praha 9   fax: +420 2 9654 2374
Czech Republic   http://www.suse.cz/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: progressive.patch
Type: text/x-diff
Size: 2406 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050401/e18d411e/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: repeat.patch
Type: text/x-diff
Size: 903 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050401/e18d411e/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gwenpic1.jpg
Type: image/jpeg
Size: 11482 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20050401/e18d411e/attachment.jpg>


More information about the kfm-devel mailing list