Closed
Bug 325906
Opened 19 years ago
Closed 18 years ago
Remove one malloc from the JPEG decoder, and some optimizations
Categories
(Core :: Graphics: ImageLib, defect)
Core
Graphics: ImageLib
Tracking
()
VERIFIED
FIXED
People
(Reporter: alfredkayser, Assigned: alfredkayser)
References
Details
Attachments
(1 file, 2 obsolete files)
21.66 KB,
patch
|
alfredkayser
:
review+
pavlov
:
superreview+
|
Details | Diff | Splinter Review |
Right now in libjpeg, the structure decoder_source_mgr is dynamically allocated using PR_NEWZAP, however it is 32 byte structure allways used in the nsJPEGDecoder, so we can make it a fixed part of nsJPEGDecoder.
Also the members related to just the source_mgr can be moved to that structure to make it easier to access them (mBuffer, mBufferLen, etc).
Furthermore, the mBackBuffer allocates with increments of 16 bytes, but the general pattern then becomes 64 bytes, 128 bytes, 192 bytes, or something like that. Making it into chunks of 256 bytes, only one allocation of mBackBuffer is generally required, instead three. (This is based on some analysis of this allocation during web browsing).
This patch will remove some cruft, like replacing a two value enum and switch statement with a boolean. mPasses and mCompletedPasses are dead and can be removed.
Assignee | ||
Comment 1•19 years ago
|
||
Attachment #210708 -
Flags: review?
Assignee | ||
Updated•19 years ago
|
Attachment #210708 -
Flags: review? → review?(pavlov)
Assignee | ||
Comment 2•19 years ago
|
||
Cleaner version, by making the struct jpeg_source_mgr part of nsJPEGDecoder itself, removing the extra structure.
Attachment #210708 -
Attachment is obsolete: true
Attachment #211763 -
Flags: review?(pavlov)
Attachment #210708 -
Flags: review?(pavlov)
Assignee | ||
Comment 3•19 years ago
|
||
The second patch makes jpeg_source_mgr a member of nsJPEGDecoder itself, and in the callback functions derives from the parameter jd->src the decoder pointer itself, so that it can directly reference to the members of the nsJPEGDecoder.
Note, the second patch is slightly bigger because:
* it also fixes the bug in the errorhandler with the errorcode translation (missing 'break' before the 'default:'
* the diff is completely confused by the whitespace change in fill_input_buffer in combination with the src->decoder-> replacement with decoder->
Comment 4•18 years ago
|
||
Comment on attachment 211763 [details] [diff] [review]
V2: Slightly cleaner version
i didn't actually check that this still builds but it looks good. sorry for taking so long :(
Attachment #211763 -
Flags: review?(pavlov) → review+
Comment 5•18 years ago
|
||
The v2 patch is bitrotted badly. I'm un-bitrotting it and confirming it builds with MSVC2005 and will post it when I'm done.
Comment 6•18 years ago
|
||
As I said in my last message, this is the same patch but made off the current trunk. I've also verified that this compiles with MSVC 2005 and that JPEG rendering seems to be OK.
One thing I noticed when carrying over the patch is that there were some differences in nsJPEGDecoder::OutputScanlines(). Some of the changes in the v2 patch were already existent in there, so you might want to make sure that the changes this patch intends to make to that function are still desired.
Attachment #211763 -
Attachment is obsolete: true
Attachment #248594 -
Flags: superreview?(pavlov)
Attachment #248594 -
Flags: review?(alfredkayser)
Assignee | ||
Comment 7•18 years ago
|
||
Comment on attachment 248594 [details] [diff] [review]
Un-bitrotted patch v2
Ok by me. Thanks for reviving this one!
Attachment #248594 -
Flags: review?(alfredkayser) → review+
Comment 8•18 years ago
|
||
Comment on attachment 248594 [details] [diff] [review]
Un-bitrotted patch v2
can one of you check it in or do you need me to do it?
Attachment #248594 -
Flags: superreview?(pavlov) → superreview+
Comment 9•18 years ago
|
||
I don't have a CVS account
Assignee | ||
Comment 10•18 years ago
|
||
Me neither, so if some one else can do the honour?
Updated•18 years ago
|
Whiteboard: [needs-checkin]
Updated•18 years ago
|
Whiteboard: [needs-checkin] → [checkin needed]
Updated•18 years ago
|
Assignee: pavlov → alfredkayser
Comment 11•18 years ago
|
||
mozilla/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.cpp 1.68
mozilla/modules/libpr0n/decoders/jpeg/nsJPEGDecoder.h 1.23
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Whiteboard: [checkin needed]
Comment 12•18 years ago
|
||
thanks gavin for landing this
Assignee | ||
Comment 13•18 years ago
|
||
Note: This patch generated some warnings.
I will check if I can fix those
Assignee | ||
Comment 14•18 years ago
|
||
gmake[6]: Entering directory `/builds/tinderbox/Fx-Trunk-Cairo/Linux_2.4.21-32.0.1.EL_Depend/mozilla/modules/libpr0n/decoders/jpeg'
nsJPEGDecoder.cpp
c++ -o nsJPEGDecoder.o -c -DMOZILLA_INTERNAL_API -DOSTYPE=\"Linux2.4.21-32.0.1\" -DOSARCH=\"Linux\" -DBUILD_ID=2007010412 -I../../../../dist/include/xpcom -I../../../../dist/include/string -I../../../../dist/include/gfx -I../../../../dist/include/imglib2 -I../../../../dist/include/jpeg -I../../../../dist/include -I../../../../dist/include/imgjpeg -I../../../../dist/include/nspr -DMOZ_PNG_READ -DMOZ_PNG_WRITE -I../../../../dist/sdk/include -I/usr/X11R6/include -I/usr/X11R6/include -fno-rtti -fno-exceptions -Wall -Wconversion -Wpointer-arith -Wcast-align -Woverloaded-virtual -Wsynth -Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wno-long-long -pedantic -fshort-wchar -pthread -pipe -DNDEBUG -DTRIMMED -O -I/usr/X11R6/include -DMOZILLA_CLIENT -include ../../../../mozilla-config.h -Wp,-MD,.deps/nsJPEGDecoder.pp nsJPEGDecoder.cpp
nsJPEGDecoder.cpp: In member function `virtual nsresult
nsJPEGDecoder::WriteFrom(nsIInputStream*, unsigned int, PRUint32*)':
nsJPEGDecoder.cpp:186: warning: unused variable `nsresult rv'
nsJPEGDecoder.cpp: In member function `PRBool
nsJPEGDecoder::OutputScanlines()':
nsJPEGDecoder.cpp:481: warning: unused variable `const int row_stride'
nsJPEGDecoder.cpp: In function `void skip_input_data(jpeg_decompress_struct*,
long int)':
nsJPEGDecoder.cpp:651: warning: invalid offsetof from non-POD type `class
nsJPEGDecoder'; use pointer to member instead
nsJPEGDecoder.cpp: In function `boolean
fill_input_buffer(jpeg_decompress_struct*)':
nsJPEGDecoder.cpp:688: warning: invalid offsetof from non-POD type `class
nsJPEGDecoder'; use pointer to member instead
nsJPEGDecoder.cpp: In function `void term_source(jpeg_decompress_struct*)':
nsJPEGDecoder.cpp:781: warning: invalid offsetof from non-POD type `class
nsJPEGDecoder'; use pointer to member instead
Assignee | ||
Comment 15•18 years ago
|
||
See bug 366214 for the followup to remove the warnings and some more optimizations.
Assignee | ||
Updated•16 years ago
|
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•