[libpng16] New 'tools' directory containing tools used to generate libpng code.

This commit is contained in:
John Bowler 2011-11-28 23:57:45 -06:00 committed by Glenn Randers-Pehrson
parent 8888ea4479
commit 405a398b3e
8 changed files with 159 additions and 23 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.6.0alpha01 - November 28, 2011
Libpng 1.6.0alpha01 - November 29, 2011
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@ -107,7 +107,7 @@ Version 1.5.7beta05 [(PENDING RELEASE)]
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.
Version 1.6.0alpha01 [November 28, 2011]
Version 1.6.0alpha01 [November 29, 2011]
Removed machine-generated configure files from the GIT repository (they will
continue to appear in the tarball distributions).
Restored the new 'simplified' API, which was deleted from libpng-1.5.7.
@ -130,7 +130,7 @@ Version 1.6.0alpha01 [November 28, 2011]
image that has a sufficiently large row size (rather than simply failing
to read such images).
Replaced an "#if" with "ifdef" in pngrtran.c
Revised #if PNG_DO_BC blocks in png.c (use #ifdef and add #else)
New tools directory containing tools used to generate libpng code.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit

View File

@ -3752,7 +3752,7 @@ Version 1.5.7beta05 [(PENDING RELEASE)]
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.
Version 1.6.0alpha01 [November 28, 2011]
Version 1.6.0alpha01 [November 29, 2011]
Removed machine-generated configure files from the GIT repository (they will
continue to appear in the tarball distributions).
Restored the new 'simplified' API, which was deleted from libpng-1.5.7.
@ -3775,7 +3775,7 @@ Version 1.6.0alpha01 [November 28, 2011]
image that has a sufficiently large row size (rather than simply failing
to read such images).
Replaced an "#if" with "ifdef" in pngrtran.c
Revised #if PNG_DO_BC blocks in png.c (use #ifdef and add #else)
New tools directory containing tools used to generate libpng code.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -28,7 +28,7 @@
#include "../../png.h"
#include "../sRGBtables/sRGB.h"
#include "../tools/sRGB.h"
/* The following is to support direct compilation of this file as C++ */
#ifdef __cplusplus

26
contrib/tools/README.txt Normal file
View File

@ -0,0 +1,26 @@
This directory (contrib/tools) contains tools used by the authors of libpng.
Code and data placed in this directory is not required to build libpng,
however the code in this directory has been used to generate data or code in
the body of the libpng source. The source code idenftifies where this has
been done. Code in this directory may not compile on all operating systems
that libpng supports.
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
To the extent possible under law, the authors have waived all copyright and
related or neighboring rights to this work. This work is published from:
United States.
The files may be used freely in any way.
The source code and comments in this directory are the original work of the
people named below. No other person or organization has made contributions to
the work in this directory.
ORIGINAL AUTHORS
The following people have contributed to the code in this directory. None
of the people below claim any rights with regard to the contents of this
directory.
John Bowler <jbowler@acm.org>

View File

@ -1,14 +1,14 @@
/*-
* convert.c
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
*
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Convert 8-bit sRGB or 16-bit linear values to another format.
*
* Last changed in libpng 1.5.7 [(PENDING RELEASE)]
* Copyright (c) 2011 Written by John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#define _ISOC99_SOURCE 1

110
contrib/tools/intgamma.sh Normal file
View File

@ -0,0 +1,110 @@
#!/bin/sh
#
# intgamma.sh
#
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
#
# COPYRIGHT: Written by John Cunningham Bowler, 2011.
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Shell script to generate png.c 8 and 16 bit log tables (see the code in png.c
# for details).
#
# This script uses the "bc" arbitrary precision calculator to calculate 32 bit
# fixed point values of logarithms appropriate to finding the log of an 8-bit
# (0..255) value and a similar table for the exponent calculation.
#
# "bc" must be on the path when the script is executed, the math library (-l)
# must be available
#
# function to print out a list of numbers as integers; the function truncates
# the integers which must be one-per-line
function print(){
awk 'BEGIN{
str = ""
}
{
sub("\\.[0-9]*$", "")
if ($0 == "")
$0 = "0"
if (str == "")
t = " " $0 "U"
else
t = str ", " $0 "U"
if (length(t) >= 80) {
print str ","
str = " " $0 "U"
} else
str = t
}
END{
print str
}'
}
#
# The logarithm table.
cat <<END
/* 8-bit log table: png_8bit_l2[128]
* This is a table of -log(value/255)/log(2) for 'value' in the range 128 to
* 255, so it's the base 2 logarithm of a normalized 8-bit floating point
* mantissa. The numbers are 32-bit fractions.
*/
static const png_uint_32
png_8bit_l2[128] =
{
END
#
bc -lqws <<END | print
f=65536*65536/l(2)
for (i=128;i<256;++i) { .5 - l(i/255)*f; }
END
echo '};'
echo
#
# The exponent table.
cat <<END
/* The 'exp()' case must invert the above, taking a 20-bit fixed point
* logarithmic value and returning a 16 or 8-bit number as appropriate. In
* each case only the low 16 bits are relevant - the fraction - since the
* integer bits (the top 4) simply determine a shift.
*
* The worst case is the 16-bit distinction between 65535 and 65534, this
* requires perhaps spurious accuracty in the decoding of the logarithm to
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
* of getting this accuracy in practice.
*
* To deal with this the following exp() function works out the exponent of the
* frational part of the logarithm by using an accurate 32-bit value from the
* top four fractional bits then multiplying in the remaining bits.
*/
static const png_uint_32
png_32bit_exp[16] =
{
END
#
bc -lqws <<END | print
f=l(2)/16
for (i=0;i<16;++i) {
x = .5 + e(-i*f)*2^32;
if (x >= 2^32) x = 2^32-1;
x;
}
END
echo '};'
echo
#
# And the table of adjustment values.
cat <<END
/* Adjustment table; provided to explain the numbers in the code below. */
#if 0
END
bc -lqws <<END | awk '{ printf "%5d %s\n", 12-NR, $0 }'
for (i=11;i>=0;--i){
(1 - e(-(2^i)/65536*l(2))) * 2^(32-i)
}
END
echo '#endif'

View File

@ -1,11 +1,11 @@
/* makesRGB.c -- build sRGB-to-linear and linear-to-sRGB conversion tables
*
* Last changed in libpng 1.5.7 [(PENDING RELEASE)]
* Copyright (c) 2011 John Cunningham Bowler
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Make a table to convert 8-bit sRGB encoding values into the closest 16-bit
* linear value.

View File

@ -1,12 +1,12 @@
/*-
* sRGB.h
*
* Last changed in libpng 1.5.7 [(PENDING RELEASE)]
* Copyright (c) 2011 John Cunningham Bowler
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Utility file; not actually a header, this contains definitions of sRGB
* calculation functions for inclusion in those test programs that need them.