Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fixed point png decoding.

7 views
Skip to first unread message

met...@gmail.com

unread,
Dec 26, 2007, 7:38:48 PM12/26/07
to pa...@samsung.com, joon...@samsung.com
I try to modify some code for fixedpoint png decoder of mozilla.
I worked on firefox-3.0-alpha7.

Refer to Pepper Computer's patches
see : http://wiki.mozilla.org/Mobile/Patches
But that patches don't include full patches for the png decoder.

Tested simple xul application includes png image(996kb) on PXA320
Processor.

Floating point png decoding time : 0.7543 sec.
Fixed Point png decoding time : 0.6897 sec.


here :

+++ mozilla/modules/libimg/png/mozpngconf.h 2007-12-20
15:05:19.000000000 +0900
@@ -110,7 +110,11 @@

#define PNG_NO_INFO_IMAGE
#define PNG_NO_USER_MEM
+#define MOZ_FIXED_PNG /* If you don't want modify the configure
option, define here */
+#ifdef MOZ_FIXED_PNG
+#define PNG_NO_FLOATING_POINT_SUPPORTED
+#else
#define PNG_NO_FIXED_POINT_SUPPORTED
+#endif /*MOZ_FIXED_PNG */
#define PNG_NO_MNG_FEATURES
#define PNG_NO_USER_TRANSFORM_PTR
#define PNG_NO_HANDLE_AS_UNKNOWN

+++ mozilla/modules/libpr0n/decoders/png/nsPNGDecoder.cpp 2007-12-21
16:57:56.000000000 +0900
@@ -275,6 +275,7 @@
return rv;
}

+#ifndef MOZ_FIXED_PNG
// Adapted from http://www.littlecms.com/pngchrm.c example code
static cmsHPROFILE
PNGGetColorProfile(png_structp png_ptr, png_infop info_ptr,


@@ -388,6 +387,7 @@

return profile;
}
+#endif //MOZ_FIXED_PNG

void
info_callback(png_structp png_ptr, png_infop info_ptr)
@@ -428,10 +428,12 @@
png_set_strip_16(png_ptr);

PRUint32 inType, intent;
+#ifndef MOZ_FIXED_PNG
if (gfxPlatform::IsCMSEnabled()) {
decoder->mInProfile = PNGGetColorProfile(png_ptr, info_ptr,
color_type, &inType,
&intent);
}
+#endif //MOZ_FIXED_PNG
if (decoder->mInProfile && gfxPlatform::GetCMSOutputProfile()) {
PRUint32 outType;

@@ -463,6 +465,7 @@
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);

+#ifndef MOZ_FIXED_PNG
if (png_get_gAMA(png_ptr, info_ptr, &aGamma)) {
if ((aGamma <= 0.0) || (aGamma > 21474.83)) {
aGamma = 0.45455;
@@ -472,12 +475,14 @@
}
else
png_set_gamma(png_ptr, 2.2, 0.45455);
+#endif //MOZ_FIXED_PNG
}

if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png_ptr);

+#ifndef MOZ_FIXED_PNG
if (png_get_gAMA(png_ptr, info_ptr, &aGamma)) {
if ((aGamma <= 0.0) || (aGamma > 21474.83)) {
aGamma = 0.45455;
@@ -487,6 +492,7 @@
}
else
png_set_gamma(png_ptr, 2.2, 0.45455);
+#endif //MOZ_FIXED_PNG

/* let libpng expand interlaced images */
if (interlace_type == PNG_INTERLACE_ADAM7) {

joone

unread,
Jan 6, 2008, 9:10:58 PM1/6/08
to
> // Adapted fromhttp://www.littlecms.com/pngchrm.cexample code

As you know, we can build the libpng fixed point routines like the
above patch.
(Use #define PNG_NO_FLOATING_POINT_SUPPORTED in mozilla/modules/libimg/
png/mozpngconf.h )

In this case, he can get 8.6% performance improvement.
It's great. I think this patch is valuable to use on Mobile Firefox.

However, there is the following problem in this patch.
Mozilla handles some floating point values to get image information
from the libpng so the patch commented out those parts in the
info_callback() function. (mozilla/modules/libpr0n/decoders/png/
nsPNGDecoder.cpp)
The problem is that the color management feature should get color
profile information from the libpng. The following code shows the
example:

void
info_callback(png_structp png_ptr, png_infop info_ptr)

{
...

if (gfxPlatform::IsCMSEnabled()) {
decoder->mInProfile = PNGGetColorProfile(png_ptr, info_ptr,
color_type, &inType, &intent);
}

...
}

We can check the value of gfx.color_management.enabled through the
gfxPlatform::IsCMSEnable() method.

If the gfx.color_management.enabled is true, Mozilla should call the
PNGGetColorProfile() method. But this method handles floating point
values.

Fortunately, Mozilla sets the value of gfx.color_management.enabled to
false as default. The PNGGetColorProfile() method is not called.
Nevertheless, the patch commented this part because a user may try to
set the value to true.
Anyway, the color management feature is not used basically now.

If Mobile Firefox should use the color management feature, the png
patch needs more tweaks as he said.

How do you think about that?

0 new messages