# HG changeset patch # User reimar # Date 1239480496 0 # Node ID 74342058fc9dfa0a844d48def9692208483cc2cb # Parent ecf9f13948f16e007b25193f2d10f5c70a975cfe Explain the purpose of the wc3_pal_lookup and the formula that was used to calculate it. diff -r ecf9f13948f1 -r 74342058fc9d wc3movie.c --- a/wc3movie.c Sat Apr 11 18:58:55 2009 +0000 +++ b/wc3movie.c Sat Apr 11 20:08:16 2009 +0000 @@ -72,7 +72,18 @@ } Wc3DemuxContext; -/* bizarre palette lookup table */ +/** + * palette lookup table that does gamma correction + * + * can be calculated by this formula: + * for i between 0 and 252 inclusive: + * wc3_pal_lookup[i] = pow(i / 256.0, 0.8) * 256; + * values 253, 254 and 255 are all 0xFD + * calculating this at runtime should not cause any + * rounding issues, the maximum difference between + * the table values and the calculated doubles is + * about 0.497527 + */ static const unsigned char wc3_pal_lookup[] = { 0x00, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0E, 0x10, 0x12, 0x13, 0x15, 0x16, 0x18, 0x19, 0x1A,