Software

All patches are copyrighted by me and licensed with the respective licenses of the patched source distributions.

Mesa extension for correct blending

2006-04-21

If OpenGL is used for creating images with transparency, and images and drawing primitives are rendered on transparent background, the OpenGL Blending functions in standard do not blend the colours correctly. In case the background is completely transparent, and a semitransparent (translucent) colour or image is drawn on top of that, the usual Blending Function behaves incorrectly:

glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
The extended version of this common function fixes the problem with incorrect Alpha values in the resulting image, but fails to fix the color channels:
glBlendFuncSeparateEXT (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
                        GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
The color channels are mixed with these settings with this formula: (Example for Red)
Rd = destination Red
Ad = destination Alpha
Rs = source Red
As = source Alpha
R' = result destination Red
A' = result destination Alpha

A' = As + (1 - As) * Ad
R' = As * Rs + (1 - As) * Rd

Example:
As = 0.5
Rs = 0.8
Ad = 0
Rd = 0.2

R' = As * Rs + (1 - As) * Ad = 0.5 * 0.8 + 0.5 * 0.2
   = 0.5
This is incorrect, the correct R' is obviously 0.8, because Ad = 0, and Rd should not affect the resulting colour at all! The solution is to compute the R' by weighing the Rs and Rd with their alphas relative to resulting alpha:
R' = As/A' * Rs + (1-As/A1) * Rd

R' = 0.5/0.5 * 0.8 + (1-0.5/0.5) * 0.2
   = 1 * 0.8 + 0 * 0.2
   = 0.8
This is correct. These patches create extension GL_FORECA_blend_relative that introduces Blending Functions GL_SRC_ALPHA_RELATIVE_FORECA and GL_ONE_MINUS_SRC_ALPHA_RELATIVE_FORECA that can be used to implement the latter formula:
http://www.iki.fi/hyvatti/sw/Mesa-6.4.2-ext-foreca.diff
http://www.iki.fi/hyvatti/sw/Mesa-6.5-ext-foreca.diff
http://www.iki.fi/hyvatti/sw/Mesa-7.0.2-ext-foreca.diff
http://www.iki.fi/hyvatti/sw/Mesa-7.6.1-ext-foreca.diff

Use this to set the correct blending function:

     glBlendFuncSeparateEXT
                    (/* sfactorRGB */ GL_SRC_ALPHA_RELATIVE_FORECA,
                     /* dfactorRGB */ GL_ONE_MINUS_SRC_ALPHA_RELATIVE_FORECA,
                     /* sfactorA   */ GL_ONE,
                     /* dfactorA   */ GL_ONE_MINUS_SRC_ALPHA);

ECC utilities

Until now, I have thought that it is almost impossible to enable ECC functionality after the BIOS has booted the computer. Many people in the ECC mailing list have confirmed that, and I have not known of anyone even attempting that seriously. The problem is that all of memory has to be written to with correct checksum mode enabled before the checking and correction of errors can be enabled. This is usually done in BIOS, as there are no other processes running.

Today, 2005-06-21, I noticed however that using the Athlon64 hardware scrubbing feature allows the memory to be initialized completely before enabling the checking of memory reads. The scripts below have worked for me, and I have verified that the correct ECC modes are enabled (with ecc.pl), and that single bit errors introduced by grounding memory data leads result in correct reports in CPU Northbridge registers.

Testing the ECC functionality can be done with following steps:

  1. Use ecc-start.sh or ecc-chip-kill-start.sh.
  2. Run ecc.pl to see that ECC is enabled and that the syndrome registers are zero.
  3. Short circuit a data line or preferably a parity bit data line on one of the DDR memory modules with ground for a short period. For example pin 49 (parity bit 2, ie. bit 66) and pin 51 (parity bit 3 = bit 67) are fine. The pin between them is Ground. Count the pins from a DIMM where number 1 pin is marked. It is easy to stuff a lead to the DIMM socket into the holes next to the socket pins. I used 10 ohm resistor to make the probability of damage smaller. However I am not responsible for any damage you cause for your computer. It can break completely.
  4. Run ecc.pl to see if the syndrome codes are there. If not, repeat the previous step.
  5. Decode the syndrome code with AMD document 26094.PDF or the table in ecc.pl. See if it corresponds with the data lead you just shorted.

wget-1.9.1 and partial file downloads

wget-1.9.1-foreca.diff implements options --skip-bytes and --limit-bytes for the GNU wget. With these options the FTP or HTTP protocol is used to only download requested portion of the remote file. FTP download works first by using the REST, restart, command to start download at --skip-bytes value, and then the data connection is interrupted when --limit-bytes mark is reached. WIth HTTP, the Range: header is used to request a part of the file.

FTGL 2.0.9, 2.0.11, 2.1.2, 2.2trunk fix

When opening bitmap fonts like X11 PCF fonts with Freetype2 and FTGL as FTGLPixmapFont, FTGL incorrectly does not check for bitmap type returned from Freetype2. In case of PCL fonts for example, the bitmap is FT_PIXEL_MODE_MONO bitmap and not the FT_PIXEL_MODE_GRAY type requested. This fixes the issue by converting from bitmap to pixmap. This bug is still present in 2.1.2 and SourceForge svn trunk, I'll try to contact the authors again.

For the svn trunk: ftgl-2.2trunk-bitmapfont.diff
For the most current release version:FTGL-2.1.2.bitmapfont.diff
For old versions:ftgl-2.0.11.bitmap-pixmap.diff

giflib-4.1.4 fixes

giflib-4.1.4.diff fixes a couple of permissions problems when writing gif's and then fixes the giftext utility. It did not print gif comments correctly. Original source: giflib-4.1.4.tar.bz2

Multiple passwords enabled for mod_auth_mysql

mod_auth_mysql-2.20-multiple.diff introduces a new directive to Apache configuration:

Auth_MySQL_Multiple_Passwords on/off
    Whether or not to allow multiple passwords.  If the database table
    includes multiple rows for single username and this is set to 'On',
    accept any one of the passwords.  If this is 'Off', multiple rows on
    password table for one username results in an error.  Default:  Off.

Animated GIF output for PHP, updated 2004-11-02

PHP developers: please consider including these patches to PHP-4, PHP-5, and PHP-6:

These do not include libgd patches, please upgrade the bundled library to gd-2.0.30 also. The patches below include libgd changes also, but it is I think better to track the official version. Thank you.

php-5.0.2-gifanim.diff - and php-4.3.9-gifanim.diff - patches to php-5.0.2 and -4.3.9. Implements functions for creating fairly optimized GIF89a animations. The configuration part of the patch might not be as beautiful as it could, I hope someone of the developer could help here. I hope this gets included in future releases of PHP.

The patch implements three new functions, imagegifanimbegin(), imagegifanimadd(), and imagegifanimend(). With these functions, animated gif images can be created on the fly with php. The documentation for the functions is included in php-doc-anim.diff (this may be outdated). Note that the animations are not optimized as heavily as with some programs like gifsicle, but if you plan carefully you can get fairly good optimization on the fly.

I am in no way promoting GIF format over such superior formats as PNG, MNG or JPEG, but for some todays applications GIF format still has its uses. For example PNG and MNG are not supported in any 3G mobile terminals and GIF89A is the only way to create animations for visually attractive content. Even Mozilla project does not include MNG support for their code by default, so GIF89A is the only option.

Note! If you are using mod_perl also with Apache, you must not use the included libgd in php distribution, but you have to configure with external php library, the same one perl GD module uses. Otherwise you will get segmentation faults.

Animated gif output for GD-2, updated 2004-11-02

gd-2.0.30 includes my patches. Below you can find what I submitted to Thomas Boutell. Please use gd-2.0.30 instead of these patches.

gd-2.0.28-gifanim.diff - a patch to gd-2.0.28 to make it write animated gif files. The documentation is also updated. Also, a new function gdImageOpenPolygon is present. I needed it to quickly draw continuous lines without closing it to a polygon shape. This version now includes also pretty good optimization. I hope this will be included in the next release of gd.

This patch does not include the changes for gif support any more as it is already present in gd-2.0.28 since the patents expired. This site used to carry a good selection of gif patches for gd: http://www.rime.com.au/gd/.

One small change with freetype font handling is also included. The error message "Could not set character size" is removed and the error from FT_Set_Char_Size() function is ignored. This allows X font files to be used more easily.

Animated gif output for perl GD module

GD-2.16-gifanim.diff - a patch to perl module that implements the perl interface to the above patched gd-2.0.28. Includes full documentation.

Microchip PIC microcontroller programmer

See the documentation for details. The current software is picprog-1.7.tar.gz.

/robots.txt updating tool

A perl script to collect robots.txt files around the WWW document tree and user directories, and collate them to a single /robots.txt.

makerobots.pl

Electric Fence 2.0.1 and 2.1

I made some changes to the Electric Fence 2.0.1 by Bruce Perens, Bruce@Pixar.com to make it useful for me, and called this version by number 2.1. I hope you agree with the changes: The original sources are efence-2.0.1.tar.gz and the modified version is efence-2.1.tar.gz. What I changed is obvious from the diff file.

HTML article contents list creator

This small perl script luvut.perl creates contents listing to a HTML document based on H-tags.

Linux malloc debugger

Simple hooks I have used when finding malloc memory leaks and corruptions. This is quite out-of-date, and I do not recommend it.

Grab debug_malloc-1.1.tar.gz here.

Outdated stuff

ECC module for linux i386

I have patched the current Linux ECC release ecc-0.12 to support AMD 761 chipset and to support hardware scrubbing and multiple error reporting. The base distribution does not allow the module to detect any errors after the first one, as it does not clear the error condition in the chipset registers. Currently this is enabled for amd 751, amd 761, intel 430hx and intel 440bx chipsets. It is easy to enable it for other chipsets also, if you just dig up the information from the documentation.

Diffs relative to ecc-0.12 are here: ecc-0.12-jh.diff. Pathched source is here: ecc-0.12-jh.tar.gz.

Force named to use tcp

A patch to BIND version 8.1: force named to use tcp always in queries. This was necessary to test a thing.. propably does not interest you.

cdda2wav 0.8 patch

To prevent certain errors when reading my cd drive, I needed to patch it a bit: cdda2wav0.8.diff.

GNU GPL and LGPL

All the software here, unless mentioned otherwise, is copyrighted material. If not included in the packages, you can access the GNU General Public License or GNU Library General Public License or later versions in http://www.funet.fi/pub/gnu/prep/ (Finland) or ftp://prep.ai.mit.edu/pub/gnu/ (original GNU site).
Jaakko Hyvätti, Jaakko.Hyvatti@iki.fi, +358 40 5011222