plug-ins: big formatting and indentation cleanup in file-dds

Also change the license to GPL 3 or later, like all other files.
This commit is contained in:
Michael Natterer 2019-05-23 14:34:00 +02:00
parent 1c91578bb2
commit 2a48a5f868
17 changed files with 3315 additions and 2857 deletions

View file

@ -1,56 +1,58 @@
/*
DDS GIMP plugin
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <math.h>
#include "color.h"
int linear_to_sRGB(int c)
int
linear_to_sRGB(int c)
{
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.0031308f)
v = 12.92f * v;
else
v = 1.055f * powf(v, 0.41666f) - 0.055f;
return((int)floorf(255.0f * v + 0.5f));
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.0031308f)
v = 12.92f * v;
else
v = 1.055f * powf(v, 0.41666f) - 0.055f;
return (int)floorf(255.0f * v + 0.5f);
}
int sRGB_to_linear(int c)
int
sRGB_to_linear(int c)
{
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.04045f)
v /= 12.92f;
else
v = powf((v + 0.055f) / 1.055f, 2.4f);
return((int)floorf(255.0f * v + 0.5f));
float v = (float)c / 255.0f;
if(v < 0)
v = 0;
else if(v > 1)
v = 1;
else if(v <= 0.04045f)
v /= 12.92f;
else
v = powf((v + 0.055f) / 1.055f, 2.4f);
return (int)floorf(255.0f * v + 0.5f);
}

View file

@ -1,27 +1,25 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef COLOR_H
#define COLOR_H
#ifndef __COLOR_H__
#define __COLOR_H__
#include "imath.h"
@ -30,62 +28,69 @@ int linear_to_sRGB(int c);
int sRGB_to_linear(int c);
/* YCoCg encoding */
static inline void RGB_to_YCoCg(unsigned char *dst, int r, int g, int b)
static inline void
RGB_to_YCoCg (unsigned char *dst, int r, int g, int b)
{
int y = ((r + (g << 1) + b) + 2) >> 2;
int co = ((((r << 1) - (b << 1)) + 2) >> 2) + 128;
int cg = (((-r + (g << 1) - b) + 2) >> 2) + 128;
int y = ((r + (g << 1) + b) + 2) >> 2;
int co = ((((r << 1) - (b << 1)) + 2) >> 2) + 128;
int cg = (((-r + (g << 1) - b) + 2) >> 2) + 128;
dst[0] = 255;
dst[1] = (cg > 255 ? 255 : (cg < 0 ? 0 : cg));
dst[2] = (co > 255 ? 255 : (co < 0 ? 0 : co));
dst[3] = (y > 255 ? 255 : (y < 0 ? 0 : y));
dst[0] = 255;
dst[1] = (cg > 255 ? 255 : (cg < 0 ? 0 : cg));
dst[2] = (co > 255 ? 255 : (co < 0 ? 0 : co));
dst[3] = (y > 255 ? 255 : (y < 0 ? 0 : y));
}
/* other color conversions */
static inline int rgb_to_luminance(int r, int g, int b)
static inline int
rgb_to_luminance (int r, int g, int b)
{
/* ITU-R BT.709 luma coefficents, scaled by 256 */
return(((r * 54 + g * 182 + b * 20) + 128) >> 8);
/* ITU-R BT.709 luma coefficents, scaled by 256 */
return ((r * 54 + g * 182 + b * 20) + 128) >> 8;
}
static inline unsigned short pack_r5g6b5(int r, int g, int b)
static inline unsigned short
pack_r5g6b5 (int r, int g, int b)
{
return((mul8bit(r, 31) << 11) |
(mul8bit(g, 63) << 5) |
(mul8bit(b, 31) ));
return (mul8bit(r, 31) << 11) |
(mul8bit(g, 63) << 5) |
(mul8bit(b, 31) );
}
static inline unsigned short pack_rgba4(int r, int g, int b, int a)
static inline unsigned short
pack_rgba4 (int r, int g, int b, int a)
{
return((mul8bit(a, 15) << 12) |
(mul8bit(r, 15) << 8) |
(mul8bit(g, 15) << 4) |
(mul8bit(b, 15) ));
return (mul8bit(a, 15) << 12) |
(mul8bit(r, 15) << 8) |
(mul8bit(g, 15) << 4) |
(mul8bit(b, 15) );
}
static inline unsigned short pack_rgb5a1(int r, int g, int b, int a)
static inline unsigned short
pack_rgb5a1 (int r, int g, int b, int a)
{
return((((a >> 7) & 0x01) << 15) |
(mul8bit(r, 31) << 10) |
(mul8bit(g, 31) << 5) |
(mul8bit(b, 31) ));
return (((a >> 7) & 0x01) << 15) |
(mul8bit(r, 31) << 10) |
(mul8bit(g, 31) << 5) |
(mul8bit(b, 31) );
}
static inline unsigned char pack_r3g3b2(int r, int g, int b)
static inline unsigned char
pack_r3g3b2(int r, int g, int b)
{
return((mul8bit(r, 7) << 5) |
(mul8bit(g, 7) << 2) |
(mul8bit(b, 3) ));
return (mul8bit(r, 7) << 5) |
(mul8bit(g, 7) << 2) |
(mul8bit(b, 3) );
}
static inline unsigned int pack_rgb10a2(int r, int g, int b, int a)
static inline unsigned int
pack_rgb10a2 (int r, int g, int b, int a)
{
return(((unsigned int)((a >> 6) & 0x003) << 30) |
((unsigned int)((r << 2) & 0x3ff) << 20) |
((unsigned int)((g << 2) & 0x3ff) << 10) |
((unsigned int)((b << 2) & 0x3ff) ));
return ((unsigned int)((a >> 6) & 0x003) << 30) |
((unsigned int)((r << 2) & 0x3ff) << 20) |
((unsigned int)((g << 2) & 0x3ff) << 10) |
((unsigned int)((b << 2) & 0x3ff) );
}
#endif
#endif /* __COLOR_H__ */

View file

@ -37,6 +37,7 @@
#include "dds.h"
#include "misc.h"
static void query (void);
static void run (const gchar *name,
gint nparams,
@ -44,6 +45,7 @@ static void run (const gchar *name,
gint *nreturn_vals,
GimpParam **return_vals);
GimpPlugInInfo PLUG_IN_INFO =
{
0,
@ -52,7 +54,6 @@ GimpPlugInInfo PLUG_IN_INFO =
run
};
DDSWriteVals dds_write_vals =
{
DDS_COMPRESS_NONE,
@ -73,55 +74,57 @@ DDSWriteVals dds_write_vals =
DDSReadVals dds_read_vals =
{
1,
1
1,
1
};
static GimpParamDef load_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_STRING, "filename", "The name of the file to load"},
{GIMP_PDB_STRING, "raw_filename", "The name entered"},
{GIMP_PDB_INT32, "load_mipmaps", "Load mipmaps if present"},
{GIMP_PDB_INT32, "decode_images", "Decode YCoCg/AExp images when detected"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_STRING, "filename", "The name of the file to load"},
{ GIMP_PDB_STRING, "raw_filename", "The name entered"},
{ GIMP_PDB_INT32, "load_mipmaps", "Load mipmaps if present"},
{ GIMP_PDB_INT32, "decode_images", "Decode YCoCg/AExp images when detected"}
};
static GimpParamDef load_return_vals[] =
{
{GIMP_PDB_IMAGE, "image", "Output image"}
{ GIMP_PDB_IMAGE, "image", "Output image"}
};
static GimpParamDef save_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image"},
{GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"},
{GIMP_PDB_STRING, "filename", "The name of the file to save the image as"},
{GIMP_PDB_STRING, "raw_filename", "The name entered"},
{GIMP_PDB_INT32, "compression_format", "Compression format (0 = None, 1 = BC1/DXT1, 2 = BC2/DXT3, 3 = BC3/DXT5, 4 = BC3n/DXT5nm, 5 = BC4/ATI1N, 6 = BC5/ATI2N, 7 = RXGB (DXT5), 8 = Alpha Exponent (DXT5), 9 = YCoCg (DXT5), 10 = YCoCg scaled (DXT5))"},
{GIMP_PDB_INT32, "mipmaps", "How to handle mipmaps (0 = No mipmaps, 1 = Generate mipmaps, 2 = Use existing mipmaps (layers)"},
{GIMP_PDB_INT32, "savetype", "How to save the image (0 = selected layer, 1 = cube map, 2 = volume map, 3 = texture array"},
{GIMP_PDB_INT32, "format", "Custom pixel format (0 = default, 1 = R5G6B5, 2 = RGBA4, 3 = RGB5A1, 4 = RGB10A2)"},
{GIMP_PDB_INT32, "transparent_index", "Index of transparent color or -1 to disable (for indexed images only)."},
{GIMP_PDB_INT32, "mipmap_filter", "Filtering to use when generating mipmaps (0 = default, 1 = nearest, 2 = box, 3 = triangle, 4 = quadratic, 5 = bspline, 6 = mitchell, 7 = lanczos, 8 = kaiser)"},
{GIMP_PDB_INT32, "mipmap_wrap", "Wrap mode to use when generating mipmaps (0 = default, 1 = mirror, 2 = repeat, 3 = clamp)"},
{GIMP_PDB_INT32, "gamma_correct", "Use gamma correct mipmap filtering"},
{GIMP_PDB_INT32, "srgb", "Use sRGB colorspace for gamma correction"},
{GIMP_PDB_FLOAT, "gamma", "Gamma value to use for gamma correction (i.e. 2.2)"},
{GIMP_PDB_INT32, "perceptual_metric", "Use a perceptual error metric during compression"},
{GIMP_PDB_INT32, "preserve_alpha_coverage", "Preserve alpha test converage for alpha channel maps"},
{GIMP_PDB_FLOAT, "alpha_test_threshold", "Alpha test threshold value for which alpha test converage should be preserved"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_IMAGE, "image", "Input image"},
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"},
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image as"},
{ GIMP_PDB_STRING, "raw_filename", "The name entered"},
{ GIMP_PDB_INT32, "compression_format", "Compression format (0 = None, 1 = BC1/DXT1, 2 = BC2/DXT3, 3 = BC3/DXT5, 4 = BC3n/DXT5nm, 5 = BC4/ATI1N, 6 = BC5/ATI2N, 7 = RXGB (DXT5), 8 = Alpha Exponent (DXT5), 9 = YCoCg (DXT5), 10 = YCoCg scaled (DXT5))"},
{ GIMP_PDB_INT32, "mipmaps", "How to handle mipmaps (0 = No mipmaps, 1 = Generate mipmaps, 2 = Use existing mipmaps (layers)"},
{ GIMP_PDB_INT32, "savetype", "How to save the image (0 = selected layer, 1 = cube map, 2 = volume map, 3 = texture array"},
{ GIMP_PDB_INT32, "format", "Custom pixel format (0 = default, 1 = R5G6B5, 2 = RGBA4, 3 = RGB5A1, 4 = RGB10A2)"},
{ GIMP_PDB_INT32, "transparent_index", "Index of transparent color or -1 to disable (for indexed images only)."},
{ GIMP_PDB_INT32, "mipmap_filter", "Filtering to use when generating mipmaps (0 = default, 1 = nearest, 2 = box, 3 = triangle, 4 = quadratic, 5 = bspline, 6 = mitchell, 7 = lanczos, 8 = kaiser)"},
{ GIMP_PDB_INT32, "mipmap_wrap", "Wrap mode to use when generating mipmaps (0 = default, 1 = mirror, 2 = repeat, 3 = clamp)"},
{ GIMP_PDB_INT32, "gamma_correct", "Use gamma correct mipmap filtering"},
{ GIMP_PDB_INT32, "srgb", "Use sRGB colorspace for gamma correction"},
{ GIMP_PDB_FLOAT, "gamma", "Gamma value to use for gamma correction (i.e. 2.2)"},
{ GIMP_PDB_INT32, "perceptual_metric", "Use a perceptual error metric during compression"},
{ GIMP_PDB_INT32, "preserve_alpha_coverage", "Preserve alpha test converage for alpha channel maps"},
{ GIMP_PDB_FLOAT, "alpha_test_threshold", "Alpha test threshold value for which alpha test converage should be preserved"}
};
static GimpParamDef decode_args[] =
{
{GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{GIMP_PDB_IMAGE, "image", "Input image"},
{GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"}
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive"},
{ GIMP_PDB_IMAGE, "image", "Input image"},
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to save"}
};
MAIN ()
static void
query (void)
{
@ -225,7 +228,7 @@ run (const gchar *name,
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
if (!strcmp (name, LOAD_PROC))
if (! strcmp (name, LOAD_PROC))
{
switch (run_mode)
{
@ -233,12 +236,14 @@ run (const gchar *name,
gimp_ui_init ("dds", 0);
gimp_get_data (LOAD_PROC, &dds_read_vals);
break;
case GIMP_RUN_NONINTERACTIVE:
dds_read_vals.mipmaps = param[3].data.d_int32;
dds_read_vals.decode_images = param[4].data.d_int32;
if (nparams != G_N_ELEMENTS (load_args))
status = GIMP_PDB_CALLING_ERROR;
break;
default:
break;
}
@ -256,12 +261,14 @@ run (const gchar *name,
gimp_set_data (LOAD_PROC, &dds_read_vals, sizeof (dds_read_vals));
}
else if (status != GIMP_PDB_CANCEL)
status = GIMP_PDB_EXECUTION_ERROR;
{
status = GIMP_PDB_EXECUTION_ERROR;
}
}
}
else if (!strcmp (name, SAVE_PROC))
else if (! strcmp (name, SAVE_PROC))
{
imageID = param[1].data.d_int32;
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
switch (run_mode)
@ -280,6 +287,7 @@ run (const gchar *name,
values[0].data.d_status = GIMP_PDB_CANCEL;
return;
}
default:
break;
}
@ -289,48 +297,70 @@ run (const gchar *name,
case GIMP_RUN_INTERACTIVE:
gimp_get_data (SAVE_PROC, &dds_write_vals);
break;
case GIMP_RUN_NONINTERACTIVE:
if (nparams != G_N_ELEMENTS (save_args))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
else
{
dds_write_vals.compression = param[5].data.d_int32;
dds_write_vals.mipmaps = param[6].data.d_int32;
dds_write_vals.savetype = param[7].data.d_int32;
dds_write_vals.format = param[8].data.d_int32;
dds_write_vals.transindex = param[9].data.d_int32;
dds_write_vals.mipmap_filter = param[10].data.d_int32;
dds_write_vals.mipmap_wrap = param[11].data.d_int32;
dds_write_vals.gamma_correct = param[12].data.d_int32;
dds_write_vals.srgb = param[13].data.d_int32;
dds_write_vals.gamma = param[14].data.d_float;
dds_write_vals.perceptual_metric = param[15].data.d_int32;
dds_write_vals.compression = param[5].data.d_int32;
dds_write_vals.mipmaps = param[6].data.d_int32;
dds_write_vals.savetype = param[7].data.d_int32;
dds_write_vals.format = param[8].data.d_int32;
dds_write_vals.transindex = param[9].data.d_int32;
dds_write_vals.mipmap_filter = param[10].data.d_int32;
dds_write_vals.mipmap_wrap = param[11].data.d_int32;
dds_write_vals.gamma_correct = param[12].data.d_int32;
dds_write_vals.srgb = param[13].data.d_int32;
dds_write_vals.gamma = param[14].data.d_float;
dds_write_vals.perceptual_metric = param[15].data.d_int32;
dds_write_vals.preserve_alpha_coverage = param[16].data.d_int32;
dds_write_vals.alpha_test_threshold = param[17].data.d_float;
dds_write_vals.alpha_test_threshold = param[17].data.d_float;
if ((dds_write_vals.compression < DDS_COMPRESS_NONE) ||
(dds_write_vals.compression >= DDS_COMPRESS_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmaps < DDS_MIPMAP_NONE) ||
(dds_write_vals.mipmaps >= DDS_MIPMAP_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.savetype < DDS_SAVE_SELECTED_LAYER) ||
(dds_write_vals.savetype >= DDS_SAVE_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.format < DDS_FORMAT_DEFAULT) ||
(dds_write_vals.format >= DDS_FORMAT_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmap_filter < DDS_MIPMAP_FILTER_DEFAULT) ||
(dds_write_vals.mipmap_filter >= DDS_MIPMAP_FILTER_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
if ((dds_write_vals.mipmap_wrap < DDS_MIPMAP_WRAP_DEFAULT) ||
(dds_write_vals.mipmap_wrap >= DDS_MIPMAP_WRAP_MAX))
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
}
break;
case GIMP_RUN_WITH_LAST_VALS:
gimp_get_data (SAVE_PROC, &dds_write_vals);
break;
default:
break;
}
@ -353,7 +383,7 @@ run (const gchar *name,
if (export == GIMP_EXPORT_EXPORT)
gimp_image_delete (imageID);
}
else if (!strcmp (name, DECODE_YCOCG_PROC))
else if (! strcmp (name, DECODE_YCOCG_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
@ -365,7 +395,7 @@ run (const gchar *name,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
}
else if (!strcmp (name, DECODE_YCOCG_SCALED_PROC))
else if (! strcmp (name, DECODE_YCOCG_SCALED_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
@ -377,7 +407,7 @@ run (const gchar *name,
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush ();
}
else if (!strcmp (name, DECODE_ALPHA_EXP_PROC))
else if (! strcmp (name, DECODE_ALPHA_EXP_PROC))
{
imageID = param[1].data.d_int32;
drawableID = param[2].data.d_int32;
@ -390,7 +420,9 @@ run (const gchar *name,
gimp_displays_flush ();
}
else
status = GIMP_PDB_CALLING_ERROR;
{
status = GIMP_PDB_CALLING_ERROR;
}
values[0].data.d_status = status;
}

View file

@ -4,24 +4,22 @@
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef DDS_H
#define DDS_H
#ifndef __DDS_H__
#define __DDS_H__
#define FOURCC(a, b, c, d) \
((unsigned int)((unsigned int)(a) ) | \
@ -31,78 +29,78 @@
typedef enum
{
DDS_COMPRESS_NONE = 0,
DDS_COMPRESS_BC1, /* DXT1 */
DDS_COMPRESS_BC2, /* DXT3 */
DDS_COMPRESS_BC3, /* DXT5 */
DDS_COMPRESS_BC3N, /* DXT5n */
DDS_COMPRESS_BC4, /* ATI1 */
DDS_COMPRESS_BC5, /* ATI2 */
DDS_COMPRESS_RXGB, /* DXT5 */
DDS_COMPRESS_AEXP, /* DXT5 */
DDS_COMPRESS_YCOCG, /* DXT5 */
DDS_COMPRESS_YCOCGS, /* DXT5 */
DDS_COMPRESS_MAX
DDS_COMPRESS_NONE = 0,
DDS_COMPRESS_BC1, /* DXT1 */
DDS_COMPRESS_BC2, /* DXT3 */
DDS_COMPRESS_BC3, /* DXT5 */
DDS_COMPRESS_BC3N, /* DXT5n */
DDS_COMPRESS_BC4, /* ATI1 */
DDS_COMPRESS_BC5, /* ATI2 */
DDS_COMPRESS_RXGB, /* DXT5 */
DDS_COMPRESS_AEXP, /* DXT5 */
DDS_COMPRESS_YCOCG, /* DXT5 */
DDS_COMPRESS_YCOCGS, /* DXT5 */
DDS_COMPRESS_MAX
} DDS_COMPRESSION_TYPE;
typedef enum
{
DDS_SAVE_SELECTED_LAYER = 0,
DDS_SAVE_CUBEMAP,
DDS_SAVE_VOLUMEMAP,
DDS_SAVE_ARRAY,
DDS_SAVE_MAX
DDS_SAVE_SELECTED_LAYER = 0,
DDS_SAVE_CUBEMAP,
DDS_SAVE_VOLUMEMAP,
DDS_SAVE_ARRAY,
DDS_SAVE_MAX
} DDS_SAVE_TYPE;
typedef enum
{
DDS_FORMAT_DEFAULT = 0,
DDS_FORMAT_RGB8,
DDS_FORMAT_RGBA8,
DDS_FORMAT_BGR8,
DDS_FORMAT_ABGR8,
DDS_FORMAT_R5G6B5,
DDS_FORMAT_RGBA4,
DDS_FORMAT_RGB5A1,
DDS_FORMAT_RGB10A2,
DDS_FORMAT_R3G3B2,
DDS_FORMAT_A8,
DDS_FORMAT_L8,
DDS_FORMAT_L8A8,
DDS_FORMAT_AEXP,
DDS_FORMAT_YCOCG,
DDS_FORMAT_MAX
DDS_FORMAT_DEFAULT = 0,
DDS_FORMAT_RGB8,
DDS_FORMAT_RGBA8,
DDS_FORMAT_BGR8,
DDS_FORMAT_ABGR8,
DDS_FORMAT_R5G6B5,
DDS_FORMAT_RGBA4,
DDS_FORMAT_RGB5A1,
DDS_FORMAT_RGB10A2,
DDS_FORMAT_R3G3B2,
DDS_FORMAT_A8,
DDS_FORMAT_L8,
DDS_FORMAT_L8A8,
DDS_FORMAT_AEXP,
DDS_FORMAT_YCOCG,
DDS_FORMAT_MAX
} DDS_FORMAT_TYPE;
typedef enum
{
DDS_MIPMAP_NONE = 0,
DDS_MIPMAP_GENERATE,
DDS_MIPMAP_EXISTING,
DDS_MIPMAP_MAX
DDS_MIPMAP_NONE = 0,
DDS_MIPMAP_GENERATE,
DDS_MIPMAP_EXISTING,
DDS_MIPMAP_MAX
} DDS_MIPMAP;
typedef enum
{
DDS_MIPMAP_FILTER_DEFAULT = 0,
DDS_MIPMAP_FILTER_NEAREST,
DDS_MIPMAP_FILTER_BOX,
DDS_MIPMAP_FILTER_TRIANGLE,
DDS_MIPMAP_FILTER_QUADRATIC,
DDS_MIPMAP_FILTER_BSPLINE,
DDS_MIPMAP_FILTER_MITCHELL,
DDS_MIPMAP_FILTER_LANCZOS,
DDS_MIPMAP_FILTER_KAISER,
DDS_MIPMAP_FILTER_MAX
DDS_MIPMAP_FILTER_DEFAULT = 0,
DDS_MIPMAP_FILTER_NEAREST,
DDS_MIPMAP_FILTER_BOX,
DDS_MIPMAP_FILTER_TRIANGLE,
DDS_MIPMAP_FILTER_QUADRATIC,
DDS_MIPMAP_FILTER_BSPLINE,
DDS_MIPMAP_FILTER_MITCHELL,
DDS_MIPMAP_FILTER_LANCZOS,
DDS_MIPMAP_FILTER_KAISER,
DDS_MIPMAP_FILTER_MAX
} DDS_MIPMAP_FILTER;
typedef enum
{
DDS_MIPMAP_WRAP_DEFAULT = 0,
DDS_MIPMAP_WRAP_MIRROR,
DDS_MIPMAP_WRAP_REPEAT,
DDS_MIPMAP_WRAP_CLAMP,
DDS_MIPMAP_WRAP_MAX
DDS_MIPMAP_WRAP_DEFAULT = 0,
DDS_MIPMAP_WRAP_MIRROR,
DDS_MIPMAP_WRAP_REPEAT,
DDS_MIPMAP_WRAP_CLAMP,
DDS_MIPMAP_WRAP_MAX
} DDS_MIPMAP_WRAP;
#define DDS_HEADERSIZE 128
@ -151,177 +149,177 @@ typedef enum
typedef struct
{
unsigned int size;
unsigned int flags;
char fourcc[4];
unsigned int bpp;
unsigned int rmask;
unsigned int gmask;
unsigned int bmask;
unsigned int amask;
unsigned int size;
unsigned int flags;
char fourcc[4];
unsigned int bpp;
unsigned int rmask;
unsigned int gmask;
unsigned int bmask;
unsigned int amask;
} dds_pixel_format_t;
typedef struct
{
unsigned int caps1;
unsigned int caps2;
unsigned int reserved[2];
unsigned int caps1;
unsigned int caps2;
unsigned int reserved[2];
} dds_caps_t;
typedef struct
{
unsigned int magic;
unsigned int size;
unsigned int flags;
unsigned int height;
unsigned int width;
unsigned int pitch_or_linsize;
unsigned int depth;
unsigned int num_mipmaps;
union
{
struct
{
unsigned int magic1; // FOURCC "GIMP"
unsigned int magic2; // FOURCC "-DDS"
unsigned int version;
unsigned int extra_fourcc;
} gimp_dds_special;
unsigned char pad[4 * 11];
} reserved;
dds_pixel_format_t pixelfmt;
dds_caps_t caps;
unsigned int reserved2;
unsigned int magic;
unsigned int size;
unsigned int flags;
unsigned int height;
unsigned int width;
unsigned int pitch_or_linsize;
unsigned int depth;
unsigned int num_mipmaps;
union
{
struct
{
unsigned int magic1; // FOURCC "GIMP"
unsigned int magic2; // FOURCC "-DDS"
unsigned int version;
unsigned int extra_fourcc;
} gimp_dds_special;
unsigned char pad[4 * 11];
} reserved;
dds_pixel_format_t pixelfmt;
dds_caps_t caps;
unsigned int reserved2;
} dds_header_t;
typedef enum
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_FORCE_UINT = 0xffffffffUL
} DXGI_FORMAT;
typedef struct
{
DXGI_FORMAT dxgiFormat;
unsigned int resourceDimension;
unsigned int miscFlag;
unsigned int arraySize;
unsigned int reserved;
DXGI_FORMAT dxgiFormat;
unsigned int resourceDimension;
unsigned int miscFlag;
unsigned int arraySize;
unsigned int reserved;
} dds_header_dx10_t;
#endif
#endif /* __DDS_H__ */

View file

@ -4,24 +4,22 @@
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __DDSPLUGIN_H
#define __DDSPLUGIN_H
#ifndef __DDSPLUGIN_H__
#define __DDSPLUGIN_H__
#define DDS_PLUGIN_VERSION_MAJOR 3
#define DDS_PLUGIN_VERSION_MINOR 9
@ -75,4 +73,4 @@ extern GimpPDBStatusType write_dds (gchar *filename,
#define DECODE_YCOCG_SCALED_PROC "color-decode-ycocg-scaled"
#define DECODE_ALPHA_EXP_PROC "color-decode-alpha-exp"
#endif
#endif /* __DDSPLUGIN_H__ */

View file

@ -95,7 +95,7 @@ static unsigned char color_bits (unsigned int mask);
static unsigned char color_shift (unsigned int mask);
static int load_dialog (void);
static int runme = 0;
static gboolean runme = FALSE;
GimpPDBStatusType
read_dds (gchar *filename,
@ -118,14 +118,14 @@ read_dds (gchar *filename,
if (interactive_dds)
{
if (!load_dialog ())
return (GIMP_PDB_CANCEL);
return GIMP_PDB_CANCEL;
}
fp = g_fopen (filename, "rb");
if (fp == 0)
{
g_message ("Error opening file.\n");
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if (strrchr (filename, '/'))
@ -148,7 +148,7 @@ read_dds (gchar *filename,
if (!setup_dxgi_format (&hdr, &dx10hdr))
{
fclose (fp);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
}
@ -156,7 +156,7 @@ read_dds (gchar *filename,
{
fclose (fp);
g_message ("Invalid DDS header!\n");
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
/* a lot of DDS images out there don't have this for some reason -_- */
@ -279,7 +279,7 @@ read_dds (gchar *filename,
{
g_message ("Can't allocate new image.\n");
fclose (fp);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
gimp_image_set_filename (image, filename);
@ -292,7 +292,7 @@ read_dds (gchar *filename,
g_message ("Error reading palette.\n");
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
for (i = j = 0; i < 768; i += 3, j += 4)
{
@ -329,13 +329,13 @@ read_dds (gchar *filename,
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if (!load_mipmaps (fp, &hdr, &d, image, "", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
}
else if (hdr.caps.caps2 & DDSCAPS2_CUBEMAP)
@ -345,42 +345,42 @@ read_dds (gchar *filename,
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if ((hdr.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX) &&
!load_face (fp, &hdr, &d, image, "(negative x)", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if ((hdr.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEY) &&
!load_face (fp, &hdr, &d, image, "(positive y)", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if ((hdr.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY) &&
!load_face (fp, &hdr, &d, image, "(negative y)", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if ((hdr.caps.caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ) &&
!load_face (fp, &hdr, &d, image, "(positive z)", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if ((hdr.caps.caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ) &&
!load_face (fp, &hdr, &d, image, "(negative z)", &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
}
else if ((hdr.caps.caps2 & DDSCAPS2_VOLUME) &&
@ -396,7 +396,7 @@ read_dds (gchar *filename,
g_free (plane);
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
g_free (plane);
}
@ -417,7 +417,7 @@ read_dds (gchar *filename,
g_free (plane);
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
g_free (plane);
}
@ -436,13 +436,13 @@ read_dds (gchar *filename,
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
if (!load_mipmaps (fp, &hdr, &d, image, elem, &l, pixels, buf))
{
fclose (fp);
gimp_image_delete (image);
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
g_free (elem);
}
@ -462,7 +462,7 @@ read_dds (gchar *filename,
if (layers == NULL || layer_count == 0)
{
g_message ("Oops! NULL image read! Please report this!");
return (GIMP_PDB_EXECUTION_ERROR);
return GIMP_PDB_EXECUTION_ERROR;
}
gimp_image_set_active_layer (image, layers[0]);
@ -470,7 +470,7 @@ read_dds (gchar *filename,
*imageID = image;
return (GIMP_PDB_SUCCESS);
return GIMP_PDB_SUCCESS;
}
static int
@ -482,7 +482,7 @@ read_header (dds_header_t *hdr,
memset (hdr, 0, sizeof (dds_header_t));
if (fread (buf, 1, DDS_HEADERSIZE, fp) != DDS_HEADERSIZE)
return (0);
return 0;
hdr->magic = GETL32(buf);
@ -519,19 +519,19 @@ read_header (dds_header_t *hdr,
hdr->reserved.gimp_dds_special.extra_fourcc = GETL32(buf + 44);
}
return (1);
return 1;
}
static int
read_header_dx10(dds_header_dx10_t *hdr,
FILE *fp)
read_header_dx10 (dds_header_dx10_t *hdr,
FILE *fp)
{
char buf[DDS_HEADERSIZE_DX10];
memset (hdr, 0, sizeof (dds_header_dx10_t));
if (fread (buf, 1, DDS_HEADERSIZE_DX10, fp) != DDS_HEADERSIZE_DX10)
return (0);
return 0;
hdr->dxgiFormat = GETL32(buf);
hdr->resourceDimension = GETL32(buf + 4);
@ -539,7 +539,7 @@ read_header_dx10(dds_header_dx10_t *hdr,
hdr->arraySize = GETL32(buf + 12);
hdr->reserved = GETL32(buf + 16);
return (1);
return 1;
}
static int
@ -550,7 +550,7 @@ validate_header (dds_header_t *hdr)
if (hdr->magic != FOURCC ('D','D','S',' '))
{
g_message ("Invalid DDS file.\n");
return (0);
return 0;
}
if ((hdr->flags & DDSD_PITCH) == (hdr->flags & DDSD_LINEARSIZE))
@ -566,7 +566,7 @@ validate_header (dds_header_t *hdr)
(hdr->pixelfmt.flags & DDPF_RGB))
{
g_message ("Invalid pixel format.\n");
return (0);
return 0;
}
*/
fourcc = GETL32(hdr->pixelfmt.fourcc);
@ -592,7 +592,7 @@ validate_header (dds_header_t *hdr)
hdr->pixelfmt.fourcc[2],
hdr->pixelfmt.fourcc[3],
GETL32(hdr->pixelfmt.fourcc));
return (0);
return 0;
}
if (hdr->pixelfmt.flags & DDPF_RGB)
@ -603,7 +603,7 @@ validate_header (dds_header_t *hdr)
(hdr->pixelfmt.bpp != 32))
{
g_message ("Invalid BPP.\n");
return (0);
return 0;
}
}
else if (hdr->pixelfmt.flags & DDPF_LUMINANCE)
@ -612,7 +612,7 @@ validate_header (dds_header_t *hdr)
(hdr->pixelfmt.bpp != 16))
{
g_message ("Invalid BPP.\n");
return (0);
return 0;
}
hdr->pixelfmt.flags |= DDPF_RGB;
@ -660,13 +660,13 @@ validate_header (dds_header_t *hdr)
break;
default:
g_message ("Invalid pixel format.");
return (0);
return 0;
}
break;
}
}
return (1);
return 1;
}
/*
@ -691,7 +691,7 @@ setup_dxgi_format (dds_header_t *hdr,
if ((dx10hdr->resourceDimension != D3D10_RESOURCE_DIMENSION_TEXTURE1D) &&
(dx10hdr->resourceDimension != D3D10_RESOURCE_DIMENSION_TEXTURE2D) &&
(dx10hdr->resourceDimension != D3D10_RESOURCE_DIMENSION_TEXTURE3D))
return (0);
return 0;
// check for a compressed DXGI format
if ((dx10hdr->dxgiFormat >= DXGI_FORMAT_BC1_TYPELESS) &&
@ -827,11 +827,11 @@ setup_dxgi_format (dds_header_t *hdr,
break;
default: /* unsupported DXGI format */
g_message ("Unsupported DXGI format (%d)", dx10hdr->dxgiFormat);
return (0);
return 0;
}
}
return (1);
return 1;
}
@ -968,10 +968,11 @@ load_layer (FILE *fp,
!fread (buf, size, 1, fp))
{
g_message ("Unexpected EOF.\n");
return (0);
return 0;
}
if ((hdr->pixelfmt.flags & DDPF_RGB) || (hdr->pixelfmt.flags & DDPF_ALPHA))
if ((hdr->pixelfmt.flags & DDPF_RGB) ||
(hdr->pixelfmt.flags & DDPF_ALPHA))
{
z = 0;
for (y = 0, n = 0; y < height; ++y, ++n)
@ -988,7 +989,7 @@ load_layer (FILE *fp,
!fread (buf, width * d->bpp, 1, fp))
{
g_message ("Unexpected EOF.\n");
return (0);
return 0;
}
if (!(hdr->flags & DDSD_LINEARSIZE)) z = 0;
@ -1104,7 +1105,7 @@ load_layer (FILE *fp,
if (!(hdr->flags & DDSD_LINEARSIZE))
{
g_message ("Image marked as compressed, but DDSD_LINEARSIZE is not set.\n");
return (0);
return 0;
}
dst = g_malloc (width * height * d->gimp_bpp);
@ -1167,11 +1168,11 @@ load_layer (FILE *fp,
}
}
return (1);
return 1;
}
static int
load_mipmaps (FILE *fp,
load_mipmaps (FILE *fp,
dds_header_t *hdr,
dds_load_info_t *d,
gint32 image,
@ -1189,10 +1190,11 @@ load_mipmaps (FILE *fp,
for (level = 1; level < hdr->num_mipmaps; ++level)
{
if (!load_layer (fp, hdr, d, image, level, prefix, l, pixels, buf))
return (0);
return 0;
}
}
return (1);
return 1;
}
static int
@ -1206,8 +1208,9 @@ load_face (FILE *fp,
unsigned char *buf)
{
if (!load_layer (fp, hdr, d, image, 0, prefix, l, pixels, buf))
return (0);
return (load_mipmaps (fp, hdr, d, image, prefix, l, pixels, buf));
return 0;
return load_mipmaps (fp, hdr, d, image, prefix, l, pixels, buf);
}
static unsigned char
@ -1220,17 +1223,22 @@ color_bits (unsigned int mask)
if (mask & 1) ++i;
mask >>= 1;
}
return (i);
return i;
}
static unsigned char
color_shift (unsigned int mask)
{
unsigned char i = 0;
guchar i = 0;
if (!mask) return (0);
while (!((mask >> i) & 1)) ++i;
return (i);
if (! mask)
return 0;
while (!((mask >> i) & 1))
++i;
return i;
}
static void
@ -1241,7 +1249,7 @@ load_dialog_response (GtkWidget *widget,
switch (response_id)
{
case GTK_RESPONSE_OK:
runme = 1;
runme = TRUE;
default:
gtk_widget_destroy (widget);
break;
@ -1298,9 +1306,9 @@ load_dialog (void)
gtk_widget_show (dlg);
runme = 0;
runme = FALSE;
gtk_main ();
return (runme);
return runme;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,41 +1,49 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef DXT_H
#define DXT_H
#ifndef __DXT_H__
#define __DXT_H__
typedef enum dxt_flags_e
{
DXT_BC1 = 1 << 0,
DXT_BC2 = 1 << 1,
DXT_BC3 = 1 << 2,
DXT_PERCEPTUAL = 1 << 3,
DXT_BC1 = 1 << 0,
DXT_BC2 = 1 << 1,
DXT_BC3 = 1 << 2,
DXT_PERCEPTUAL = 1 << 3,
} dxt_flags_t;
int dxt_compress(unsigned char *dst, unsigned char *src, int format,
unsigned int width, unsigned int height, int bpp,
int mipmaps, int flags);
int dxt_decompress(unsigned char *dst, unsigned char *src, int format,
unsigned int size, unsigned int width, unsigned int height,
int bpp, int normals);
int dxt_compress (unsigned char *dst,
unsigned char *src,
int format,
unsigned int width,
unsigned int height,
int bpp,
int mipmaps,
int flags);
int dxt_decompress (unsigned char *dst,
unsigned char *src,
int format,
unsigned int size,
unsigned int width,
unsigned int height,
int bpp,
int normals);
#endif
#endif /* __DXT_H__ */

View file

@ -1,216 +1,216 @@
#ifndef DXT_TABLES_H
#define DXT_TABLES_H
#ifndef __DXT_TABLES_H__
#define __DXT_TABLES_H__
static const unsigned char quantRB[256 + 16] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x21, 0x21, 0x21,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x29, 0x29,
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x31, 0x31,
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x39, 0x39,
0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x4a, 0x4a,
0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x52,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x5a,
0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x6b,
0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b,
0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c,
0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94,
0x94, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c,
0x9c, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
0xa5, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
0xad, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5,
0xb5, 0xb5, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
0xbd, 0xbd, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce,
0xce, 0xce, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6,
0xd6, 0xd6, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde,
0xde, 0xde, 0xde, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7,
0xe7, 0xe7, 0xe7, 0xef, 0xef, 0xef, 0xef, 0xef,
0xef, 0xef, 0xef, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7,
0xf7, 0xf7, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x10, 0x10,
0x10, 0x10, 0x10, 0x10, 0x10, 0x18, 0x18, 0x18,
0x18, 0x18, 0x18, 0x18, 0x18, 0x21, 0x21, 0x21,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x29, 0x29,
0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x31, 0x31,
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x39, 0x39,
0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x42, 0x42,
0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x4a, 0x4a,
0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x4a, 0x52,
0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x52, 0x5a,
0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x63,
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x6b,
0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b, 0x6b,
0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73, 0x73,
0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84,
0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c, 0x8c,
0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94,
0x94, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c, 0x9c,
0x9c, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5, 0xa5,
0xa5, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad, 0xad,
0xad, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5, 0xb5,
0xb5, 0xb5, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd, 0xbd,
0xbd, 0xbd, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6,
0xc6, 0xc6, 0xce, 0xce, 0xce, 0xce, 0xce, 0xce,
0xce, 0xce, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6, 0xd6,
0xd6, 0xd6, 0xde, 0xde, 0xde, 0xde, 0xde, 0xde,
0xde, 0xde, 0xde, 0xe7, 0xe7, 0xe7, 0xe7, 0xe7,
0xe7, 0xe7, 0xe7, 0xef, 0xef, 0xef, 0xef, 0xef,
0xef, 0xef, 0xef, 0xf7, 0xf7, 0xf7, 0xf7, 0xf7,
0xf7, 0xf7, 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
static const unsigned char quantG[256 + 16] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x08,
0x08, 0x08, 0x08, 0x0c, 0x0c, 0x0c, 0x0c, 0x10,
0x10, 0x10, 0x10, 0x14, 0x14, 0x14, 0x14, 0x18,
0x18, 0x18, 0x18, 0x1c, 0x1c, 0x1c, 0x1c, 0x20,
0x20, 0x20, 0x20, 0x24, 0x24, 0x24, 0x24, 0x28,
0x28, 0x28, 0x28, 0x2c, 0x2c, 0x2c, 0x2c, 0x30,
0x30, 0x30, 0x30, 0x34, 0x34, 0x34, 0x34, 0x38,
0x38, 0x38, 0x38, 0x3c, 0x3c, 0x3c, 0x3c, 0x41,
0x41, 0x41, 0x41, 0x45, 0x45, 0x45, 0x45, 0x49,
0x49, 0x49, 0x49, 0x4d, 0x4d, 0x4d, 0x4d, 0x51,
0x51, 0x51, 0x51, 0x55, 0x55, 0x55, 0x55, 0x55,
0x59, 0x59, 0x59, 0x59, 0x5d, 0x5d, 0x5d, 0x5d,
0x61, 0x61, 0x61, 0x61, 0x65, 0x65, 0x65, 0x65,
0x69, 0x69, 0x69, 0x69, 0x6d, 0x6d, 0x6d, 0x6d,
0x71, 0x71, 0x71, 0x71, 0x75, 0x75, 0x75, 0x75,
0x79, 0x79, 0x79, 0x79, 0x7d, 0x7d, 0x7d, 0x7d,
0x82, 0x82, 0x82, 0x82, 0x86, 0x86, 0x86, 0x86,
0x8a, 0x8a, 0x8a, 0x8a, 0x8e, 0x8e, 0x8e, 0x8e,
0x92, 0x92, 0x92, 0x92, 0x96, 0x96, 0x96, 0x96,
0x9a, 0x9a, 0x9a, 0x9a, 0x9e, 0x9e, 0x9e, 0x9e,
0xa2, 0xa2, 0xa2, 0xa2, 0xa6, 0xa6, 0xa6, 0xa6,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xae, 0xae, 0xae,
0xae, 0xb2, 0xb2, 0xb2, 0xb2, 0xb6, 0xb6, 0xb6,
0xb6, 0xba, 0xba, 0xba, 0xba, 0xbe, 0xbe, 0xbe,
0xbe, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xc7, 0xc7,
0xc7, 0xcb, 0xcb, 0xcb, 0xcb, 0xcf, 0xcf, 0xcf,
0xcf, 0xd3, 0xd3, 0xd3, 0xd3, 0xd7, 0xd7, 0xd7,
0xd7, 0xdb, 0xdb, 0xdb, 0xdb, 0xdf, 0xdf, 0xdf,
0xdf, 0xe3, 0xe3, 0xe3, 0xe3, 0xe7, 0xe7, 0xe7,
0xe7, 0xeb, 0xeb, 0xeb, 0xeb, 0xef, 0xef, 0xef,
0xef, 0xf3, 0xf3, 0xf3, 0xf3, 0xf7, 0xf7, 0xf7,
0xf7, 0xfb, 0xfb, 0xfb, 0xfb, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x08,
0x08, 0x08, 0x08, 0x0c, 0x0c, 0x0c, 0x0c, 0x10,
0x10, 0x10, 0x10, 0x14, 0x14, 0x14, 0x14, 0x18,
0x18, 0x18, 0x18, 0x1c, 0x1c, 0x1c, 0x1c, 0x20,
0x20, 0x20, 0x20, 0x24, 0x24, 0x24, 0x24, 0x28,
0x28, 0x28, 0x28, 0x2c, 0x2c, 0x2c, 0x2c, 0x30,
0x30, 0x30, 0x30, 0x34, 0x34, 0x34, 0x34, 0x38,
0x38, 0x38, 0x38, 0x3c, 0x3c, 0x3c, 0x3c, 0x41,
0x41, 0x41, 0x41, 0x45, 0x45, 0x45, 0x45, 0x49,
0x49, 0x49, 0x49, 0x4d, 0x4d, 0x4d, 0x4d, 0x51,
0x51, 0x51, 0x51, 0x55, 0x55, 0x55, 0x55, 0x55,
0x59, 0x59, 0x59, 0x59, 0x5d, 0x5d, 0x5d, 0x5d,
0x61, 0x61, 0x61, 0x61, 0x65, 0x65, 0x65, 0x65,
0x69, 0x69, 0x69, 0x69, 0x6d, 0x6d, 0x6d, 0x6d,
0x71, 0x71, 0x71, 0x71, 0x75, 0x75, 0x75, 0x75,
0x79, 0x79, 0x79, 0x79, 0x7d, 0x7d, 0x7d, 0x7d,
0x82, 0x82, 0x82, 0x82, 0x86, 0x86, 0x86, 0x86,
0x8a, 0x8a, 0x8a, 0x8a, 0x8e, 0x8e, 0x8e, 0x8e,
0x92, 0x92, 0x92, 0x92, 0x96, 0x96, 0x96, 0x96,
0x9a, 0x9a, 0x9a, 0x9a, 0x9e, 0x9e, 0x9e, 0x9e,
0xa2, 0xa2, 0xa2, 0xa2, 0xa6, 0xa6, 0xa6, 0xa6,
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xae, 0xae, 0xae,
0xae, 0xb2, 0xb2, 0xb2, 0xb2, 0xb6, 0xb6, 0xb6,
0xb6, 0xba, 0xba, 0xba, 0xba, 0xbe, 0xbe, 0xbe,
0xbe, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xc7, 0xc7,
0xc7, 0xcb, 0xcb, 0xcb, 0xcb, 0xcf, 0xcf, 0xcf,
0xcf, 0xd3, 0xd3, 0xd3, 0xd3, 0xd7, 0xd7, 0xd7,
0xd7, 0xdb, 0xdb, 0xdb, 0xdb, 0xdf, 0xdf, 0xdf,
0xdf, 0xe3, 0xe3, 0xe3, 0xe3, 0xe7, 0xe7, 0xe7,
0xe7, 0xeb, 0xeb, 0xeb, 0xeb, 0xef, 0xef, 0xef,
0xef, 0xf3, 0xf3, 0xf3, 0xf3, 0xf7, 0xf7, 0xf7,
0xf7, 0xfb, 0xfb, 0xfb, 0xfb, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
};
static const unsigned char omatch5[256][2] =
{
{0x00, 0x00}, {0x00, 0x00}, {0x00, 0x01}, {0x00, 0x01},
{0x01, 0x00}, {0x01, 0x00}, {0x01, 0x00}, {0x01, 0x01},
{0x01, 0x01}, {0x01, 0x01}, {0x01, 0x02}, {0x00, 0x04},
{0x02, 0x01}, {0x02, 0x01}, {0x02, 0x01}, {0x02, 0x02},
{0x02, 0x02}, {0x02, 0x02}, {0x02, 0x03}, {0x01, 0x05},
{0x03, 0x02}, {0x03, 0x02}, {0x04, 0x00}, {0x03, 0x03},
{0x03, 0x03}, {0x03, 0x03}, {0x03, 0x04}, {0x03, 0x04},
{0x03, 0x04}, {0x03, 0x05}, {0x04, 0x03}, {0x04, 0x03},
{0x05, 0x02}, {0x04, 0x04}, {0x04, 0x04}, {0x04, 0x05},
{0x04, 0x05}, {0x05, 0x04}, {0x05, 0x04}, {0x05, 0x04},
{0x06, 0x03}, {0x05, 0x05}, {0x05, 0x05}, {0x05, 0x06},
{0x04, 0x08}, {0x06, 0x05}, {0x06, 0x05}, {0x06, 0x05},
{0x06, 0x06}, {0x06, 0x06}, {0x06, 0x06}, {0x06, 0x07},
{0x05, 0x09}, {0x07, 0x06}, {0x07, 0x06}, {0x08, 0x04},
{0x07, 0x07}, {0x07, 0x07}, {0x07, 0x07}, {0x07, 0x08},
{0x07, 0x08}, {0x07, 0x08}, {0x07, 0x09}, {0x08, 0x07},
{0x08, 0x07}, {0x09, 0x06}, {0x08, 0x08}, {0x08, 0x08},
{0x08, 0x09}, {0x08, 0x09}, {0x09, 0x08}, {0x09, 0x08},
{0x09, 0x08}, {0x0a, 0x07}, {0x09, 0x09}, {0x09, 0x09},
{0x09, 0x0a}, {0x08, 0x0c}, {0x0a, 0x09}, {0x0a, 0x09},
{0x0a, 0x09}, {0x0a, 0x0a}, {0x0a, 0x0a}, {0x0a, 0x0a},
{0x0a, 0x0b}, {0x09, 0x0d}, {0x0b, 0x0a}, {0x0b, 0x0a},
{0x0c, 0x08}, {0x0b, 0x0b}, {0x0b, 0x0b}, {0x0b, 0x0b},
{0x0b, 0x0c}, {0x0b, 0x0c}, {0x0b, 0x0c}, {0x0b, 0x0d},
{0x0c, 0x0b}, {0x0c, 0x0b}, {0x0d, 0x0a}, {0x0c, 0x0c},
{0x0c, 0x0c}, {0x0c, 0x0d}, {0x0c, 0x0d}, {0x0d, 0x0c},
{0x0d, 0x0c}, {0x0d, 0x0c}, {0x0e, 0x0b}, {0x0d, 0x0d},
{0x0d, 0x0d}, {0x0d, 0x0e}, {0x0c, 0x10}, {0x0e, 0x0d},
{0x0e, 0x0d}, {0x0e, 0x0d}, {0x0e, 0x0e}, {0x0e, 0x0e},
{0x0e, 0x0e}, {0x0e, 0x0f}, {0x0d, 0x11}, {0x0f, 0x0e},
{0x0f, 0x0e}, {0x10, 0x0c}, {0x0f, 0x0f}, {0x0f, 0x0f},
{0x0f, 0x0f}, {0x0f, 0x10}, {0x0f, 0x10}, {0x0f, 0x10},
{0x0f, 0x11}, {0x10, 0x0f}, {0x10, 0x0f}, {0x11, 0x0e},
{0x10, 0x10}, {0x10, 0x10}, {0x10, 0x11}, {0x10, 0x11},
{0x11, 0x10}, {0x11, 0x10}, {0x11, 0x10}, {0x12, 0x0f},
{0x11, 0x11}, {0x11, 0x11}, {0x11, 0x12}, {0x10, 0x14},
{0x12, 0x11}, {0x12, 0x11}, {0x12, 0x11}, {0x12, 0x12},
{0x12, 0x12}, {0x12, 0x12}, {0x12, 0x13}, {0x11, 0x15},
{0x13, 0x12}, {0x13, 0x12}, {0x14, 0x10}, {0x13, 0x13},
{0x13, 0x13}, {0x13, 0x13}, {0x13, 0x14}, {0x13, 0x14},
{0x13, 0x14}, {0x13, 0x15}, {0x14, 0x13}, {0x14, 0x13},
{0x15, 0x12}, {0x14, 0x14}, {0x14, 0x14}, {0x14, 0x15},
{0x14, 0x15}, {0x15, 0x14}, {0x15, 0x14}, {0x15, 0x14},
{0x16, 0x13}, {0x15, 0x15}, {0x15, 0x15}, {0x15, 0x16},
{0x14, 0x18}, {0x16, 0x15}, {0x16, 0x15}, {0x16, 0x15},
{0x16, 0x16}, {0x16, 0x16}, {0x16, 0x16}, {0x16, 0x17},
{0x15, 0x19}, {0x17, 0x16}, {0x17, 0x16}, {0x18, 0x14},
{0x17, 0x17}, {0x17, 0x17}, {0x17, 0x17}, {0x17, 0x18},
{0x17, 0x18}, {0x17, 0x18}, {0x17, 0x19}, {0x18, 0x17},
{0x18, 0x17}, {0x19, 0x16}, {0x18, 0x18}, {0x18, 0x18},
{0x18, 0x19}, {0x18, 0x19}, {0x19, 0x18}, {0x19, 0x18},
{0x19, 0x18}, {0x1a, 0x17}, {0x19, 0x19}, {0x19, 0x19},
{0x19, 0x1a}, {0x18, 0x1c}, {0x1a, 0x19}, {0x1a, 0x19},
{0x1a, 0x19}, {0x1a, 0x1a}, {0x1a, 0x1a}, {0x1a, 0x1a},
{0x1a, 0x1b}, {0x19, 0x1d}, {0x1b, 0x1a}, {0x1b, 0x1a},
{0x1c, 0x18}, {0x1b, 0x1b}, {0x1b, 0x1b}, {0x1b, 0x1b},
{0x1b, 0x1c}, {0x1b, 0x1c}, {0x1b, 0x1c}, {0x1b, 0x1d},
{0x1c, 0x1b}, {0x1c, 0x1b}, {0x1d, 0x1a}, {0x1c, 0x1c},
{0x1c, 0x1c}, {0x1c, 0x1d}, {0x1c, 0x1d}, {0x1d, 0x1c},
{0x1d, 0x1c}, {0x1d, 0x1c}, {0x1e, 0x1b}, {0x1d, 0x1d},
{0x1d, 0x1d}, {0x1d, 0x1e}, {0x1d, 0x1e}, {0x1e, 0x1d},
{0x1e, 0x1d}, {0x1e, 0x1d}, {0x1e, 0x1e}, {0x1e, 0x1e},
{0x1e, 0x1e}, {0x1e, 0x1f}, {0x1e, 0x1f}, {0x1f, 0x1e},
{0x1f, 0x1e}, {0x1f, 0x1e}, {0x1f, 0x1f}, {0x1f, 0x1f},
{0x00, 0x00}, {0x00, 0x00}, {0x00, 0x01}, {0x00, 0x01},
{0x01, 0x00}, {0x01, 0x00}, {0x01, 0x00}, {0x01, 0x01},
{0x01, 0x01}, {0x01, 0x01}, {0x01, 0x02}, {0x00, 0x04},
{0x02, 0x01}, {0x02, 0x01}, {0x02, 0x01}, {0x02, 0x02},
{0x02, 0x02}, {0x02, 0x02}, {0x02, 0x03}, {0x01, 0x05},
{0x03, 0x02}, {0x03, 0x02}, {0x04, 0x00}, {0x03, 0x03},
{0x03, 0x03}, {0x03, 0x03}, {0x03, 0x04}, {0x03, 0x04},
{0x03, 0x04}, {0x03, 0x05}, {0x04, 0x03}, {0x04, 0x03},
{0x05, 0x02}, {0x04, 0x04}, {0x04, 0x04}, {0x04, 0x05},
{0x04, 0x05}, {0x05, 0x04}, {0x05, 0x04}, {0x05, 0x04},
{0x06, 0x03}, {0x05, 0x05}, {0x05, 0x05}, {0x05, 0x06},
{0x04, 0x08}, {0x06, 0x05}, {0x06, 0x05}, {0x06, 0x05},
{0x06, 0x06}, {0x06, 0x06}, {0x06, 0x06}, {0x06, 0x07},
{0x05, 0x09}, {0x07, 0x06}, {0x07, 0x06}, {0x08, 0x04},
{0x07, 0x07}, {0x07, 0x07}, {0x07, 0x07}, {0x07, 0x08},
{0x07, 0x08}, {0x07, 0x08}, {0x07, 0x09}, {0x08, 0x07},
{0x08, 0x07}, {0x09, 0x06}, {0x08, 0x08}, {0x08, 0x08},
{0x08, 0x09}, {0x08, 0x09}, {0x09, 0x08}, {0x09, 0x08},
{0x09, 0x08}, {0x0a, 0x07}, {0x09, 0x09}, {0x09, 0x09},
{0x09, 0x0a}, {0x08, 0x0c}, {0x0a, 0x09}, {0x0a, 0x09},
{0x0a, 0x09}, {0x0a, 0x0a}, {0x0a, 0x0a}, {0x0a, 0x0a},
{0x0a, 0x0b}, {0x09, 0x0d}, {0x0b, 0x0a}, {0x0b, 0x0a},
{0x0c, 0x08}, {0x0b, 0x0b}, {0x0b, 0x0b}, {0x0b, 0x0b},
{0x0b, 0x0c}, {0x0b, 0x0c}, {0x0b, 0x0c}, {0x0b, 0x0d},
{0x0c, 0x0b}, {0x0c, 0x0b}, {0x0d, 0x0a}, {0x0c, 0x0c},
{0x0c, 0x0c}, {0x0c, 0x0d}, {0x0c, 0x0d}, {0x0d, 0x0c},
{0x0d, 0x0c}, {0x0d, 0x0c}, {0x0e, 0x0b}, {0x0d, 0x0d},
{0x0d, 0x0d}, {0x0d, 0x0e}, {0x0c, 0x10}, {0x0e, 0x0d},
{0x0e, 0x0d}, {0x0e, 0x0d}, {0x0e, 0x0e}, {0x0e, 0x0e},
{0x0e, 0x0e}, {0x0e, 0x0f}, {0x0d, 0x11}, {0x0f, 0x0e},
{0x0f, 0x0e}, {0x10, 0x0c}, {0x0f, 0x0f}, {0x0f, 0x0f},
{0x0f, 0x0f}, {0x0f, 0x10}, {0x0f, 0x10}, {0x0f, 0x10},
{0x0f, 0x11}, {0x10, 0x0f}, {0x10, 0x0f}, {0x11, 0x0e},
{0x10, 0x10}, {0x10, 0x10}, {0x10, 0x11}, {0x10, 0x11},
{0x11, 0x10}, {0x11, 0x10}, {0x11, 0x10}, {0x12, 0x0f},
{0x11, 0x11}, {0x11, 0x11}, {0x11, 0x12}, {0x10, 0x14},
{0x12, 0x11}, {0x12, 0x11}, {0x12, 0x11}, {0x12, 0x12},
{0x12, 0x12}, {0x12, 0x12}, {0x12, 0x13}, {0x11, 0x15},
{0x13, 0x12}, {0x13, 0x12}, {0x14, 0x10}, {0x13, 0x13},
{0x13, 0x13}, {0x13, 0x13}, {0x13, 0x14}, {0x13, 0x14},
{0x13, 0x14}, {0x13, 0x15}, {0x14, 0x13}, {0x14, 0x13},
{0x15, 0x12}, {0x14, 0x14}, {0x14, 0x14}, {0x14, 0x15},
{0x14, 0x15}, {0x15, 0x14}, {0x15, 0x14}, {0x15, 0x14},
{0x16, 0x13}, {0x15, 0x15}, {0x15, 0x15}, {0x15, 0x16},
{0x14, 0x18}, {0x16, 0x15}, {0x16, 0x15}, {0x16, 0x15},
{0x16, 0x16}, {0x16, 0x16}, {0x16, 0x16}, {0x16, 0x17},
{0x15, 0x19}, {0x17, 0x16}, {0x17, 0x16}, {0x18, 0x14},
{0x17, 0x17}, {0x17, 0x17}, {0x17, 0x17}, {0x17, 0x18},
{0x17, 0x18}, {0x17, 0x18}, {0x17, 0x19}, {0x18, 0x17},
{0x18, 0x17}, {0x19, 0x16}, {0x18, 0x18}, {0x18, 0x18},
{0x18, 0x19}, {0x18, 0x19}, {0x19, 0x18}, {0x19, 0x18},
{0x19, 0x18}, {0x1a, 0x17}, {0x19, 0x19}, {0x19, 0x19},
{0x19, 0x1a}, {0x18, 0x1c}, {0x1a, 0x19}, {0x1a, 0x19},
{0x1a, 0x19}, {0x1a, 0x1a}, {0x1a, 0x1a}, {0x1a, 0x1a},
{0x1a, 0x1b}, {0x19, 0x1d}, {0x1b, 0x1a}, {0x1b, 0x1a},
{0x1c, 0x18}, {0x1b, 0x1b}, {0x1b, 0x1b}, {0x1b, 0x1b},
{0x1b, 0x1c}, {0x1b, 0x1c}, {0x1b, 0x1c}, {0x1b, 0x1d},
{0x1c, 0x1b}, {0x1c, 0x1b}, {0x1d, 0x1a}, {0x1c, 0x1c},
{0x1c, 0x1c}, {0x1c, 0x1d}, {0x1c, 0x1d}, {0x1d, 0x1c},
{0x1d, 0x1c}, {0x1d, 0x1c}, {0x1e, 0x1b}, {0x1d, 0x1d},
{0x1d, 0x1d}, {0x1d, 0x1e}, {0x1d, 0x1e}, {0x1e, 0x1d},
{0x1e, 0x1d}, {0x1e, 0x1d}, {0x1e, 0x1e}, {0x1e, 0x1e},
{0x1e, 0x1e}, {0x1e, 0x1f}, {0x1e, 0x1f}, {0x1f, 0x1e},
{0x1f, 0x1e}, {0x1f, 0x1e}, {0x1f, 0x1f}, {0x1f, 0x1f},
};
static const unsigned char omatch6[256][2] =
{
{0x00, 0x00}, {0x00, 0x01}, {0x01, 0x00}, {0x01, 0x01},
{0x01, 0x01}, {0x01, 0x02}, {0x02, 0x01}, {0x02, 0x02},
{0x02, 0x02}, {0x02, 0x03}, {0x03, 0x02}, {0x03, 0x03},
{0x03, 0x03}, {0x03, 0x04}, {0x04, 0x03}, {0x04, 0x04},
{0x04, 0x04}, {0x04, 0x05}, {0x05, 0x04}, {0x05, 0x05},
{0x05, 0x05}, {0x05, 0x06}, {0x06, 0x05}, {0x00, 0x11},
{0x06, 0x06}, {0x06, 0x07}, {0x07, 0x06}, {0x02, 0x10},
{0x07, 0x07}, {0x07, 0x08}, {0x08, 0x07}, {0x03, 0x11},
{0x08, 0x08}, {0x08, 0x09}, {0x09, 0x08}, {0x05, 0x10},
{0x09, 0x09}, {0x09, 0x0a}, {0x0a, 0x09}, {0x06, 0x11},
{0x0a, 0x0a}, {0x0a, 0x0b}, {0x0b, 0x0a}, {0x08, 0x10},
{0x0b, 0x0b}, {0x0b, 0x0c}, {0x0c, 0x0b}, {0x09, 0x11},
{0x0c, 0x0c}, {0x0c, 0x0d}, {0x0d, 0x0c}, {0x0b, 0x10},
{0x0d, 0x0d}, {0x0d, 0x0e}, {0x0e, 0x0d}, {0x0c, 0x11},
{0x0e, 0x0e}, {0x0e, 0x0f}, {0x0f, 0x0e}, {0x0e, 0x10},
{0x0f, 0x0f}, {0x0f, 0x10}, {0x10, 0x0e}, {0x10, 0x0f},
{0x11, 0x0e}, {0x10, 0x10}, {0x10, 0x11}, {0x11, 0x10},
{0x12, 0x0f}, {0x11, 0x11}, {0x11, 0x12}, {0x12, 0x11},
{0x14, 0x0e}, {0x12, 0x12}, {0x12, 0x13}, {0x13, 0x12},
{0x15, 0x0f}, {0x13, 0x13}, {0x13, 0x14}, {0x14, 0x13},
{0x17, 0x0e}, {0x14, 0x14}, {0x14, 0x15}, {0x15, 0x14},
{0x18, 0x0f}, {0x15, 0x15}, {0x15, 0x16}, {0x16, 0x15},
{0x1a, 0x0e}, {0x16, 0x16}, {0x16, 0x17}, {0x17, 0x16},
{0x1b, 0x0f}, {0x17, 0x17}, {0x17, 0x18}, {0x18, 0x17},
{0x13, 0x21}, {0x18, 0x18}, {0x18, 0x19}, {0x19, 0x18},
{0x15, 0x20}, {0x19, 0x19}, {0x19, 0x1a}, {0x1a, 0x19},
{0x16, 0x21}, {0x1a, 0x1a}, {0x1a, 0x1b}, {0x1b, 0x1a},
{0x18, 0x20}, {0x1b, 0x1b}, {0x1b, 0x1c}, {0x1c, 0x1b},
{0x19, 0x21}, {0x1c, 0x1c}, {0x1c, 0x1d}, {0x1d, 0x1c},
{0x1b, 0x20}, {0x1d, 0x1d}, {0x1d, 0x1e}, {0x1e, 0x1d},
{0x1c, 0x21}, {0x1e, 0x1e}, {0x1e, 0x1f}, {0x1f, 0x1e},
{0x1e, 0x20}, {0x1f, 0x1f}, {0x1f, 0x20}, {0x20, 0x1e},
{0x20, 0x1f}, {0x21, 0x1e}, {0x20, 0x20}, {0x20, 0x21},
{0x21, 0x20}, {0x22, 0x1f}, {0x21, 0x21}, {0x21, 0x22},
{0x22, 0x21}, {0x24, 0x1e}, {0x22, 0x22}, {0x22, 0x23},
{0x23, 0x22}, {0x25, 0x1f}, {0x23, 0x23}, {0x23, 0x24},
{0x24, 0x23}, {0x27, 0x1e}, {0x24, 0x24}, {0x24, 0x25},
{0x25, 0x24}, {0x28, 0x1f}, {0x25, 0x25}, {0x25, 0x26},
{0x26, 0x25}, {0x2a, 0x1e}, {0x26, 0x26}, {0x26, 0x27},
{0x27, 0x26}, {0x2b, 0x1f}, {0x27, 0x27}, {0x27, 0x28},
{0x28, 0x27}, {0x23, 0x31}, {0x28, 0x28}, {0x28, 0x29},
{0x29, 0x28}, {0x25, 0x30}, {0x29, 0x29}, {0x29, 0x2a},
{0x2a, 0x29}, {0x26, 0x31}, {0x2a, 0x2a}, {0x2a, 0x2b},
{0x2b, 0x2a}, {0x28, 0x30}, {0x2b, 0x2b}, {0x2b, 0x2c},
{0x2c, 0x2b}, {0x29, 0x31}, {0x2c, 0x2c}, {0x2c, 0x2d},
{0x2d, 0x2c}, {0x2b, 0x30}, {0x2d, 0x2d}, {0x2d, 0x2e},
{0x2e, 0x2d}, {0x2c, 0x31}, {0x2e, 0x2e}, {0x2e, 0x2f},
{0x2f, 0x2e}, {0x2e, 0x30}, {0x2f, 0x2f}, {0x2f, 0x30},
{0x30, 0x2e}, {0x30, 0x2f}, {0x31, 0x2e}, {0x30, 0x30},
{0x30, 0x31}, {0x31, 0x30}, {0x32, 0x2f}, {0x31, 0x31},
{0x31, 0x32}, {0x32, 0x31}, {0x34, 0x2e}, {0x32, 0x32},
{0x32, 0x33}, {0x33, 0x32}, {0x35, 0x2f}, {0x33, 0x33},
{0x33, 0x34}, {0x34, 0x33}, {0x37, 0x2e}, {0x34, 0x34},
{0x34, 0x35}, {0x35, 0x34}, {0x38, 0x2f}, {0x35, 0x35},
{0x35, 0x36}, {0x36, 0x35}, {0x3a, 0x2e}, {0x36, 0x36},
{0x36, 0x37}, {0x37, 0x36}, {0x3b, 0x2f}, {0x37, 0x37},
{0x37, 0x38}, {0x38, 0x37}, {0x3d, 0x2e}, {0x38, 0x38},
{0x38, 0x39}, {0x39, 0x38}, {0x3e, 0x2f}, {0x39, 0x39},
{0x39, 0x3a}, {0x3a, 0x39}, {0x3a, 0x3a}, {0x3a, 0x3a},
{0x3a, 0x3b}, {0x3b, 0x3a}, {0x3b, 0x3b}, {0x3b, 0x3b},
{0x3b, 0x3c}, {0x3c, 0x3b}, {0x3c, 0x3c}, {0x3c, 0x3c},
{0x3c, 0x3d}, {0x3d, 0x3c}, {0x3d, 0x3d}, {0x3d, 0x3d},
{0x3d, 0x3e}, {0x3e, 0x3d}, {0x3e, 0x3e}, {0x3e, 0x3e},
{0x3e, 0x3f}, {0x3f, 0x3e}, {0x3f, 0x3f}, {0x3f, 0x3f},
{0x00, 0x00}, {0x00, 0x01}, {0x01, 0x00}, {0x01, 0x01},
{0x01, 0x01}, {0x01, 0x02}, {0x02, 0x01}, {0x02, 0x02},
{0x02, 0x02}, {0x02, 0x03}, {0x03, 0x02}, {0x03, 0x03},
{0x03, 0x03}, {0x03, 0x04}, {0x04, 0x03}, {0x04, 0x04},
{0x04, 0x04}, {0x04, 0x05}, {0x05, 0x04}, {0x05, 0x05},
{0x05, 0x05}, {0x05, 0x06}, {0x06, 0x05}, {0x00, 0x11},
{0x06, 0x06}, {0x06, 0x07}, {0x07, 0x06}, {0x02, 0x10},
{0x07, 0x07}, {0x07, 0x08}, {0x08, 0x07}, {0x03, 0x11},
{0x08, 0x08}, {0x08, 0x09}, {0x09, 0x08}, {0x05, 0x10},
{0x09, 0x09}, {0x09, 0x0a}, {0x0a, 0x09}, {0x06, 0x11},
{0x0a, 0x0a}, {0x0a, 0x0b}, {0x0b, 0x0a}, {0x08, 0x10},
{0x0b, 0x0b}, {0x0b, 0x0c}, {0x0c, 0x0b}, {0x09, 0x11},
{0x0c, 0x0c}, {0x0c, 0x0d}, {0x0d, 0x0c}, {0x0b, 0x10},
{0x0d, 0x0d}, {0x0d, 0x0e}, {0x0e, 0x0d}, {0x0c, 0x11},
{0x0e, 0x0e}, {0x0e, 0x0f}, {0x0f, 0x0e}, {0x0e, 0x10},
{0x0f, 0x0f}, {0x0f, 0x10}, {0x10, 0x0e}, {0x10, 0x0f},
{0x11, 0x0e}, {0x10, 0x10}, {0x10, 0x11}, {0x11, 0x10},
{0x12, 0x0f}, {0x11, 0x11}, {0x11, 0x12}, {0x12, 0x11},
{0x14, 0x0e}, {0x12, 0x12}, {0x12, 0x13}, {0x13, 0x12},
{0x15, 0x0f}, {0x13, 0x13}, {0x13, 0x14}, {0x14, 0x13},
{0x17, 0x0e}, {0x14, 0x14}, {0x14, 0x15}, {0x15, 0x14},
{0x18, 0x0f}, {0x15, 0x15}, {0x15, 0x16}, {0x16, 0x15},
{0x1a, 0x0e}, {0x16, 0x16}, {0x16, 0x17}, {0x17, 0x16},
{0x1b, 0x0f}, {0x17, 0x17}, {0x17, 0x18}, {0x18, 0x17},
{0x13, 0x21}, {0x18, 0x18}, {0x18, 0x19}, {0x19, 0x18},
{0x15, 0x20}, {0x19, 0x19}, {0x19, 0x1a}, {0x1a, 0x19},
{0x16, 0x21}, {0x1a, 0x1a}, {0x1a, 0x1b}, {0x1b, 0x1a},
{0x18, 0x20}, {0x1b, 0x1b}, {0x1b, 0x1c}, {0x1c, 0x1b},
{0x19, 0x21}, {0x1c, 0x1c}, {0x1c, 0x1d}, {0x1d, 0x1c},
{0x1b, 0x20}, {0x1d, 0x1d}, {0x1d, 0x1e}, {0x1e, 0x1d},
{0x1c, 0x21}, {0x1e, 0x1e}, {0x1e, 0x1f}, {0x1f, 0x1e},
{0x1e, 0x20}, {0x1f, 0x1f}, {0x1f, 0x20}, {0x20, 0x1e},
{0x20, 0x1f}, {0x21, 0x1e}, {0x20, 0x20}, {0x20, 0x21},
{0x21, 0x20}, {0x22, 0x1f}, {0x21, 0x21}, {0x21, 0x22},
{0x22, 0x21}, {0x24, 0x1e}, {0x22, 0x22}, {0x22, 0x23},
{0x23, 0x22}, {0x25, 0x1f}, {0x23, 0x23}, {0x23, 0x24},
{0x24, 0x23}, {0x27, 0x1e}, {0x24, 0x24}, {0x24, 0x25},
{0x25, 0x24}, {0x28, 0x1f}, {0x25, 0x25}, {0x25, 0x26},
{0x26, 0x25}, {0x2a, 0x1e}, {0x26, 0x26}, {0x26, 0x27},
{0x27, 0x26}, {0x2b, 0x1f}, {0x27, 0x27}, {0x27, 0x28},
{0x28, 0x27}, {0x23, 0x31}, {0x28, 0x28}, {0x28, 0x29},
{0x29, 0x28}, {0x25, 0x30}, {0x29, 0x29}, {0x29, 0x2a},
{0x2a, 0x29}, {0x26, 0x31}, {0x2a, 0x2a}, {0x2a, 0x2b},
{0x2b, 0x2a}, {0x28, 0x30}, {0x2b, 0x2b}, {0x2b, 0x2c},
{0x2c, 0x2b}, {0x29, 0x31}, {0x2c, 0x2c}, {0x2c, 0x2d},
{0x2d, 0x2c}, {0x2b, 0x30}, {0x2d, 0x2d}, {0x2d, 0x2e},
{0x2e, 0x2d}, {0x2c, 0x31}, {0x2e, 0x2e}, {0x2e, 0x2f},
{0x2f, 0x2e}, {0x2e, 0x30}, {0x2f, 0x2f}, {0x2f, 0x30},
{0x30, 0x2e}, {0x30, 0x2f}, {0x31, 0x2e}, {0x30, 0x30},
{0x30, 0x31}, {0x31, 0x30}, {0x32, 0x2f}, {0x31, 0x31},
{0x31, 0x32}, {0x32, 0x31}, {0x34, 0x2e}, {0x32, 0x32},
{0x32, 0x33}, {0x33, 0x32}, {0x35, 0x2f}, {0x33, 0x33},
{0x33, 0x34}, {0x34, 0x33}, {0x37, 0x2e}, {0x34, 0x34},
{0x34, 0x35}, {0x35, 0x34}, {0x38, 0x2f}, {0x35, 0x35},
{0x35, 0x36}, {0x36, 0x35}, {0x3a, 0x2e}, {0x36, 0x36},
{0x36, 0x37}, {0x37, 0x36}, {0x3b, 0x2f}, {0x37, 0x37},
{0x37, 0x38}, {0x38, 0x37}, {0x3d, 0x2e}, {0x38, 0x38},
{0x38, 0x39}, {0x39, 0x38}, {0x3e, 0x2f}, {0x39, 0x39},
{0x39, 0x3a}, {0x3a, 0x39}, {0x3a, 0x3a}, {0x3a, 0x3a},
{0x3a, 0x3b}, {0x3b, 0x3a}, {0x3b, 0x3b}, {0x3b, 0x3b},
{0x3b, 0x3c}, {0x3c, 0x3b}, {0x3c, 0x3c}, {0x3c, 0x3c},
{0x3c, 0x3d}, {0x3d, 0x3c}, {0x3d, 0x3d}, {0x3d, 0x3d},
{0x3d, 0x3e}, {0x3e, 0x3d}, {0x3e, 0x3e}, {0x3e, 0x3e},
{0x3e, 0x3f}, {0x3f, 0x3e}, {0x3f, 0x3f}, {0x3f, 0x3f},
};
#endif
#endif /* __DXT_TABLES_H__ */

View file

@ -1,71 +1,69 @@
/*
DDS GIMP plugin
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef ENDIAN_RW_H
#define ENDIAN_RW_H
#define GETL64(buf) \
(((unsigned long long)(buf)[0] ) | \
((unsigned long long)(buf)[1] << 8) | \
((unsigned long long)(buf)[2] << 16) | \
((unsigned long long)(buf)[3] << 24) | \
((unsigned long long)(buf)[4] << 32) | \
((unsigned long long)(buf)[5] << 40) | \
((unsigned long long)(buf)[6] << 48) | \
((unsigned long long)(buf)[7] << 56))
#define GETL32(buf) \
(((unsigned int)(buf)[0] ) | \
((unsigned int)(buf)[1] << 8) | \
((unsigned int)(buf)[2] << 16) | \
((unsigned int)(buf)[3] << 24))
#define GETL24(buf) \
(((unsigned int)(buf)[0] ) | \
((unsigned int)(buf)[1] << 8) | \
((unsigned int)(buf)[2] << 16))
#define GETL16(buf) \
(((unsigned short)(buf)[0] ) | \
((unsigned short)(buf)[1] << 8))
#define PUTL16(buf, s) \
(buf)[0] = ((s) ) & 0xff; \
(buf)[1] = ((s) >> 8) & 0xff;
#define PUTL32(buf, l) \
(buf)[0] = ((l) ) & 0xff; \
(buf)[1] = ((l) >> 8) & 0xff; \
(buf)[2] = ((l) >> 16) & 0xff; \
(buf)[3] = ((l) >> 24) & 0xff;
#define PUTL64(buf, ll) \
(buf)[0] = ((ll) ) & 0xff; \
(buf)[1] = ((ll) >> 8) & 0xff; \
(buf)[2] = ((ll) >> 16) & 0xff; \
(buf)[3] = ((ll) >> 24) & 0xff; \
(buf)[4] = ((ll) >> 32) & 0xff; \
(buf)[5] = ((ll) >> 40) & 0xff; \
(buf)[6] = ((ll) >> 48) & 0xff; \
(buf)[7] = ((ll) >> 56) & 0xff;
#endif
/*
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __ENDIAN_RW_H__
#define __ENDIAN_RW_H__
#define GETL64(buf) \
(((unsigned long long)(buf)[0] ) | \
((unsigned long long)(buf)[1] << 8) | \
((unsigned long long)(buf)[2] << 16) | \
((unsigned long long)(buf)[3] << 24) | \
((unsigned long long)(buf)[4] << 32) | \
((unsigned long long)(buf)[5] << 40) | \
((unsigned long long)(buf)[6] << 48) | \
((unsigned long long)(buf)[7] << 56))
#define GETL32(buf) \
(((unsigned int)(buf)[0] ) | \
((unsigned int)(buf)[1] << 8) | \
((unsigned int)(buf)[2] << 16) | \
((unsigned int)(buf)[3] << 24))
#define GETL24(buf) \
(((unsigned int)(buf)[0] ) | \
((unsigned int)(buf)[1] << 8) | \
((unsigned int)(buf)[2] << 16))
#define GETL16(buf) \
(((unsigned short)(buf)[0] ) | \
((unsigned short)(buf)[1] << 8))
#define PUTL16(buf, s) \
(buf)[0] = ((s) ) & 0xff; \
(buf)[1] = ((s) >> 8) & 0xff;
#define PUTL32(buf, l) \
(buf)[0] = ((l) ) & 0xff; \
(buf)[1] = ((l) >> 8) & 0xff; \
(buf)[2] = ((l) >> 16) & 0xff; \
(buf)[3] = ((l) >> 24) & 0xff;
#define PUTL64(buf, ll) \
(buf)[0] = ((ll) ) & 0xff; \
(buf)[1] = ((ll) >> 8) & 0xff; \
(buf)[2] = ((ll) >> 16) & 0xff; \
(buf)[3] = ((ll) >> 24) & 0xff; \
(buf)[4] = ((ll) >> 32) & 0xff; \
(buf)[5] = ((ll) >> 40) & 0xff; \
(buf)[6] = ((ll) >> 48) & 0xff; \
(buf)[7] = ((ll) >> 56) & 0xff;
#endif /* __ENDIAN_RW_H__ */

View file

@ -1,27 +1,25 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef IMATH_H
#define IMATH_H
#ifndef __IMATH_H__
#define __IMATH_H__
#ifndef MIN
# ifdef __GNUC__
@ -45,23 +43,35 @@
/* round integer x up to next multiple of 4 */
#define RND_MUL4(x) ((x) + (4 - ((x) & 3)))
static inline int mul8bit(int a, int b)
static inline int
mul8bit (int a,
int b)
{
int t = a * b + 128;
return((t + (t >> 8)) >> 8);
int t = a * b + 128;
return (t + (t >> 8)) >> 8;
}
static inline int blerp(int a, int b, int x)
static inline int
blerp (int a,
int b,
int x)
{
return(a + mul8bit(b - a, x));
return a + mul8bit(b - a, x);
}
static inline int icerp(int a, int b, int c, int d, int x)
static inline int
icerp (int a,
int b,
int c,
int d,
int x)
{
int p = (d - c) - (a - b);
int q = (a - b) - p;
int r = c - a;
return((x * (x * (x * p + (q << 7)) + (r << 14)) + (b << 21)) >> 21);
int p = (d - c) - (a - b);
int q = (a - b) - p;
int r = c - a;
return (x * (x * (x * p + (q << 7)) + (r << 14)) + (b << 21)) >> 21;
}
#endif
#endif /* __IMATH_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,47 +1,75 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
#ifndef __MIPMAP_H__
#define __MIPMAP_H__
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
int get_num_mipmaps (int width,
int height);
unsigned int get_mipmapped_size (int width,
int height,
int bpp,
int level,
int num,
int format);
unsigned int get_volume_mipmapped_size (int width,
int height,
int depth,
int bpp,
int level,
int num,
int format);
int get_next_mipmap_dimensions (int *next_w,
int *next_h,
int curr_w,
int curr_h);
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
float cubic_interpolate (float a,
float b,
float c,
float d,
float x);
int generate_mipmaps (unsigned char *dst,
unsigned char *src,
unsigned int width,
unsigned int height,
int bpp,
int indexed,
int mipmaps,
int filter,
int wrap,
int gamma_correct,
float gamma,
int preserve_alpha_test_coverage,
float alpha_test_threshold);
int generate_volume_mipmaps (unsigned char *dst,
unsigned char *src,
unsigned int width,
unsigned int height,
unsigned int depth,
int bpp,
int indexed,
int mipmaps,
int filter,
int wrap,
int gamma_correct,
float gamma);
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef MIPMAP_H
#define MIPMAP_H
int get_num_mipmaps(int width, int height);
unsigned int get_mipmapped_size(int width, int height, int bpp,
int level, int num, int format);
unsigned int get_volume_mipmapped_size(int width, int height,
int depth, int bpp, int level,
int num, int format);
int get_next_mipmap_dimensions(int *next_w, int *next_h,
int curr_w, int curr_h);
float cubic_interpolate(float a, float b, float c, float d, float x);
int generate_mipmaps(unsigned char *dst, unsigned char *src,
unsigned int width, unsigned int height, int bpp,
int indexed, int mipmaps, int filter, int wrap,
int gamma_correct, float gamma,
int preserve_alpha_test_coverage, float alpha_test_threshold);
int generate_volume_mipmaps(unsigned char *dst, unsigned char *src,
unsigned int width, unsigned int height,
unsigned int depth, int bpp, int indexed,
int mipmaps, int filter, int wrap,
int gamma_correct, float gamma);
#endif
#endif /* __MIPMAP_H__ */

View file

@ -1,70 +1,74 @@
/*
DDS GIMP plugin
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301, USA.
*/
#include <libgimp/gimp.h>
#include "misc.h"
static inline float saturate(float a)
static inline float
saturate (float a)
{
if(a < 0) a = 0;
if(a > 1) a = 1;
return(a);
if(a < 0) a = 0;
if(a > 1) a = 1;
return a;
}
void decode_ycocg_image(gint32 drawableID, gboolean shadow)
void
decode_ycocg_image (gint32 drawableID,
gboolean shadow)
{
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
const float offset = 0.5f * 256.0f / 255.0f;
float Y, Co, Cg, R, G, B;
const float offset = 0.5f * 256.0f / 255.0f;
float Y, Co, Cg, R, G, B;
buffer = gimp_drawable_get_buffer(drawableID);
buffer = gimp_drawable_get_buffer (drawableID);
if(shadow)
{
sbuffer = gimp_drawable_get_shadow_buffer(drawableID);
gegl_buffer_copy(buffer, NULL, GEGL_ABYSS_NONE, sbuffer, NULL);
g_object_unref(buffer);
if (shadow)
{
sbuffer = gimp_drawable_get_shadow_buffer (drawableID);
gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, sbuffer, NULL);
g_object_unref (buffer);
buffer = sbuffer;
}
format = babl_format("R'G'B'A u8");
}
w = gegl_buffer_get_width(buffer);
h = gegl_buffer_get_height(buffer);
num_pixels = w * h;
data = g_malloc(num_pixels * 4);
gegl_buffer_get(buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
format = babl_format ("R'G'B'A u8");
w = gegl_buffer_get_width (buffer);
h = gegl_buffer_get_height (buffer);
num_pixels = w * h;
data = g_malloc (num_pixels * 4);
gegl_buffer_get (buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gimp_progress_init("Decoding YCoCg pixels...");
gimp_progress_init ("Decoding YCoCg pixels...");
for(i = 0; i < num_pixels; ++i)
{
for (i = 0; i < num_pixels; ++i)
{
Y = (float)data[4 * i + 3] / 255.0f;
Co = (float)data[4 * i + 0] / 255.0f;
Cg = (float)data[4 * i + 1] / 255.0f;
@ -84,62 +88,64 @@ void decode_ycocg_image(gint32 drawableID, gboolean shadow)
data[4 * i + 1] = (unsigned char)(G * 255.0f);
data[4 * i + 2] = (unsigned char)(B * 255.0f);
if((i & 0x7fff) == 0)
gimp_progress_update((float)i / (float)num_pixels);
}
if ((i & 0x7fff) == 0)
gimp_progress_update ((float)i / (float)num_pixels);
}
gegl_buffer_set(buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
GEGL_AUTO_ROWSTRIDE);
gimp_progress_update(1.0);
gimp_progress_update (1.0);
gegl_buffer_flush(buffer);
if(shadow)
gimp_drawable_merge_shadow(drawableID, TRUE);
gimp_drawable_update(drawableID, 0, 0, w, h);
gegl_buffer_flush (buffer);
g_free(data);
g_object_unref(buffer);
if (shadow)
gimp_drawable_merge_shadow (drawableID, TRUE);
gimp_drawable_update (drawableID, 0, 0, w, h);
g_free (data);
g_object_unref (buffer);
}
void decode_ycocg_scaled_image(gint32 drawableID, gboolean shadow)
void
decode_ycocg_scaled_image (gint32 drawableID,
gboolean shadow)
{
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
const float offset = 0.5f * 256.0f / 255.0f;
float Y, Co, Cg, R, G, B, s;
const float offset = 0.5f * 256.0f / 255.0f;
float Y, Co, Cg, R, G, B, s;
buffer = gimp_drawable_get_buffer(drawableID);
if(shadow)
{
buffer = gimp_drawable_get_buffer (drawableID);
if (shadow)
{
sbuffer = gimp_drawable_get_shadow_buffer(drawableID);
gegl_buffer_copy(buffer, NULL, GEGL_ABYSS_NONE, sbuffer, NULL);
g_object_unref(buffer);
buffer = sbuffer;
}
format = babl_format("R'G'B'A u8");
w = gegl_buffer_get_width(buffer);
h = gegl_buffer_get_height(buffer);
num_pixels = w * h;
data = g_malloc(num_pixels * 4);
gegl_buffer_get(buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gimp_progress_init("Decoding YCoCg (scaled) pixels...");
}
for(i = 0; i < num_pixels; ++i)
{
format = babl_format ("R'G'B'A u8");
w = gegl_buffer_get_width (buffer);
h = gegl_buffer_get_height (buffer);
num_pixels = w * h;
data = g_malloc (num_pixels * 4);
gegl_buffer_get (buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gimp_progress_init ("Decoding YCoCg (scaled) pixels...");
for (i = 0; i < num_pixels; ++i)
{
Y = (float)data[4 * i + 3] / 255.0f;
Co = (float)data[4 * i + 0] / 255.0f;
Cg = (float)data[4 * i + 1] / 255.0f;
@ -162,60 +168,62 @@ void decode_ycocg_scaled_image(gint32 drawableID, gboolean shadow)
/* set alpha to 1 */
data[4 * i + 3] = 255;
if((i & 0x7fff) == 0)
gimp_progress_update((float)i / (float)num_pixels);
}
if ((i & 0x7fff) == 0)
gimp_progress_update ((float)i / (float)num_pixels);
}
gegl_buffer_set(buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
GEGL_AUTO_ROWSTRIDE);
gimp_progress_update(1.0);
gegl_buffer_flush(buffer);
if(shadow)
gimp_drawable_merge_shadow(drawableID, TRUE);
gimp_progress_update (1.0);
gimp_drawable_update(drawableID, 0, 0, w, h);
g_free(data);
g_object_unref(buffer);
gegl_buffer_flush (buffer);
if (shadow)
gimp_drawable_merge_shadow (drawableID, TRUE);
gimp_drawable_update (drawableID, 0, 0, w, h);
g_free (data);
g_object_unref (buffer);
}
void decode_alpha_exp_image(gint32 drawableID, gboolean shadow)
void
decode_alpha_exp_image (gint32 drawableID,
gboolean shadow)
{
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
int R, G, B, A;
GeglBuffer *buffer, *sbuffer;
const Babl *format;
unsigned char *data;
unsigned int i, w, h, num_pixels;
int R, G, B, A;
buffer = gimp_drawable_get_buffer(drawableID);
if(shadow)
{
sbuffer = gimp_drawable_get_shadow_buffer(drawableID);
gegl_buffer_copy(buffer, NULL, GEGL_ABYSS_NONE, sbuffer, NULL);
g_object_unref(buffer);
buffer = gimp_drawable_get_buffer (drawableID);
if (shadow)
{
sbuffer = gimp_drawable_get_shadow_buffer (drawableID);
gegl_buffer_copy (buffer, NULL, GEGL_ABYSS_NONE, sbuffer, NULL);
g_object_unref (buffer);
buffer = sbuffer;
}
format = babl_format("R'G'B'A u8");
w = gegl_buffer_get_width(buffer);
h = gegl_buffer_get_height(buffer);
num_pixels = w * h;
data = g_malloc(num_pixels * 4);
gegl_buffer_get(buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gimp_progress_init("Decoding Alpha-exponent pixels...");
}
for(i = 0; i < num_pixels; ++i)
{
format = babl_format ("R'G'B'A u8");
w = gegl_buffer_get_width (buffer);
h = gegl_buffer_get_height (buffer);
num_pixels = w * h;
data = g_malloc (num_pixels * 4);
gegl_buffer_get (buffer, GEGL_RECTANGLE(0, 0, w, h), 1.0, format, data,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
gimp_progress_init ("Decoding Alpha-exponent pixels...");
for (i = 0; i < num_pixels; ++i)
{
R = data[4 * i + 0];
G = data[4 * i + 1];
B = data[4 * i + 2];
@ -231,23 +239,23 @@ void decode_alpha_exp_image(gint32 drawableID, gboolean shadow)
data[4 * i + 2] = B;
data[4 * i + 3] = A;
if((i & 0x7fff) == 0)
gimp_progress_update((float)i / (float)num_pixels);
}
if ((i & 0x7fff) == 0)
gimp_progress_update ((float)i / (float)num_pixels);
}
gegl_buffer_set(buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
GEGL_AUTO_ROWSTRIDE);
gimp_progress_update(1.0);
gegl_buffer_flush(buffer);
if(shadow)
gimp_drawable_merge_shadow(drawableID, TRUE);
gimp_progress_update (1.0);
gimp_drawable_update(drawableID, 0, 0, w, h);
g_free(data);
g_object_unref(buffer);
gegl_buffer_flush (buffer);
if (shadow)
gimp_drawable_merge_shadow (drawableID, TRUE);
gimp_drawable_update (drawableID, 0, 0, w, h);
g_free (data);
g_object_unref (buffer);
}

View file

@ -1,30 +1,31 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
#ifndef __MISC_H__
#define __MISC_H__
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
void decode_ycocg_image (gint32 drawableID,
gboolean shadow);
void decode_ycocg_scaled_image (gint32 drawableID,
gboolean shadow);
void decode_alpha_exp_image (gint32 drawableID,
gboolean shadow);
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor
Boston, MA 02110-1301, USA.
*/
#ifndef MISC_H
#define MISC_H
void decode_ycocg_image(gint32 drawableID, gboolean shadow);
void decode_ycocg_scaled_image(gint32 drawableID, gboolean shadow);
void decode_alpha_exp_image(gint32 drawableID, gboolean shadow);
#endif
#endif /* __MISC_H__ */

View file

@ -1,27 +1,25 @@
/*
DDS GIMP plugin
* DDS GIMP plugin
*
* Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
* with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Copyright (C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA.
*/
#ifndef VEC_H
#define VEC_H
#ifndef __VEC_H__
#define __VEC_H__
#include <math.h>
@ -42,185 +40,206 @@ typedef float sym3x3_t[6];
#define VEC4_CONST3(x, y, z) {x, y, z, 0.0f}
#define VEC4_CONST1(x) {x, x, x, x}
static inline vec4_t vec4_set(float x, float y, float z, float w)
static inline vec4_t
vec4_set (float x,
float y,
float z,
float w)
{
#ifdef USE_SSE
return(_mm_setr_ps(x, y, z, w));
return _mm_setr_ps(x, y, z, w);
#else
vec4_t v = {x, y, z, w};
return(v);
vec4_t v = { x, y, z, w };
return v;
#endif
}
static inline vec4_t vec4_set1(float f)
static inline vec4_t
vec4_set1 (float f)
{
#ifdef USE_SSE
return(_mm_set1_ps(f));
return _mm_set1_ps(f);
#else
vec4_t v = {f, f, f, f};
return(v);
vec4_t v = { f, f, f, f };
return v;
#endif
}
static inline vec4_t vec4_zero()
static inline vec4_t
vec4_zero (void)
{
#ifdef USE_SSE
return(_mm_setzero_ps());
return _mm_setzero_ps();
#else
vec4_t v = {0, 0, 0, 0};
return(v);
vec4_t v = { 0, 0, 0, 0 };
return v;
#endif
}
static inline void vec4_store(float *f, const vec4_t v)
static inline void
vec4_store (float *f,
const vec4_t v)
{
#ifdef USE_SSE
_mm_store_ps(f, v);
_mm_store_ps (f, v);
#else
f[0] = v[0]; f[1] = v[1]; f[2] = v[2]; f[3] = v[3];
f[0] = v[0]; f[1] = v[1]; f[2] = v[2]; f[3] = v[3];
#endif
}
static inline vec4_t vec4_splatx(const vec4_t v)
static inline vec4_t
vec4_splatx (const vec4_t v)
{
#ifdef USE_SSE
return(_mm_shuffle_ps(v, v, 0x00));
return _mm_shuffle_ps(v, v, 0x00);
#else
vec4_t r = {v[0], v[0], v[0], v[0]};
return(r);
vec4_t r = { v[0], v[0], v[0], v[0] };
return r;
#endif
}
static inline vec4_t vec4_splaty(const vec4_t v)
static inline vec4_t
vec4_splaty (const vec4_t v)
{
#ifdef USE_SSE
return(_mm_shuffle_ps(v, v, 0x55));
return _mm_shuffle_ps(v, v, 0x55);
#else
vec4_t r = {v[1], v[1], v[1], v[1]};
return(r);
vec4_t r = { v[1], v[1], v[1], v[1] };
return r;
#endif
}
static inline vec4_t vec4_splatz(const vec4_t v)
static inline vec4_t
vec4_splatz (const vec4_t v)
{
#ifdef USE_SSE
return(_mm_shuffle_ps(v, v, 0xaa));
return _mm_shuffle_ps(v, v, 0xaa);
#else
vec4_t r = {v[2], v[2], v[2], v[2]};
return(r);
vec4_t r = { v[2], v[2], v[2], v[2] };
return r;
#endif
}
static inline vec4_t vec4_splatw(const vec4_t v)
static inline vec4_t
vec4_splatw (const vec4_t v)
{
#ifdef USE_SSE
return(_mm_shuffle_ps(v, v, 0xff));
return _mm_shuffle_ps(v, v, 0xff);
#else
vec4_t r = {v[3], v[3], v[3], v[3]};
return(r);
vec4_t r = { v[3], v[3], v[3], v[3] };
return r;
#endif
}
static inline vec4_t vec4_rcp(const vec4_t v)
static inline vec4_t
vec4_rcp (const vec4_t v)
{
#ifdef USE_SSE
__m128 est = _mm_rcp_ps(v);
__m128 diff = _mm_sub_ps(_mm_set1_ps(1.0f), _mm_mul_ps(est, v));
return(_mm_add_ps(_mm_mul_ps(diff, est), est));
__m128 est = _mm_rcp_ps (v);
__m128 diff = _mm_sub_ps (_mm_set1_ps(1.0f), _mm_mul_ps(est, v));
return _mm_add_ps(_mm_mul_ps(diff, est), est);
#else
vec4_t one = {1.0f, 1.0f, 1.0f, 1.0f};
return(one / v);
vec4_t one = { 1.0f, 1.0f, 1.0f, 1.0f };
return one / v;
#endif
}
static inline vec4_t vec4_min(const vec4_t a, const vec4_t b)
static inline vec4_t
vec4_min (const vec4_t a,
const vec4_t b)
{
#ifdef USE_SSE
return(_mm_min_ps(a, b));
return _mm_min_ps(a, b);
#else
return(vec4_set(MIN(a[0], b[0]), MIN(a[1], b[1]), MIN(a[2], b[2]), MIN(a[3], b[3])));
return vec4_set (MIN(a[0], b[0]), MIN(a[1], b[1]), MIN(a[2], b[2]), MIN(a[3], b[3]));
#endif
}
static inline vec4_t vec4_max(const vec4_t a, const vec4_t b)
static inline vec4_t
vec4_max (const vec4_t a,
const vec4_t b)
{
#ifdef USE_SSE
return(_mm_max_ps(a, b));
return _mm_max_ps (a, b);
#else
return(vec4_set(MAX(a[0], b[0]), MAX(a[1], b[1]), MAX(a[2], b[2]), MAX(a[3], b[3])));
return vec4_set (MAX(a[0], b[0]), MAX(a[1], b[1]), MAX(a[2], b[2]), MAX(a[3], b[3]));
#endif
}
static inline vec4_t vec4_trunc(const vec4_t v)
static inline vec4_t
vec4_trunc (const vec4_t v)
{
#ifdef USE_SSE
# ifdef __SSE4_1__
return(_mm_round_ps(v, _MM_FROUND_TRUNC));
return _mm_round_ps(v, _MM_FROUND_TRUNC);
# elif defined(__SSE2__)
return(_mm_cvtepi32_ps(_mm_cvttps_epi32(v)));
return _mm_cvtepi32_ps(_mm_cvttps_epi32(v));
# else
// convert to ints
__m128 in = v;
__m64 lo = _mm_cvttps_pi32(in);
__m64 hi = _mm_cvttps_pi32(_mm_movehl_ps(in, in));
// convert to floats
__m128 part = _mm_movelh_ps(in, _mm_cvtpi32_ps(in, hi));
__m128 trunc = _mm_cvtpi32_ps(part, lo);
// convert to ints
__m128 in = v;
__m64 lo = _mm_cvttps_pi32(in);
__m64 hi = _mm_cvttps_pi32(_mm_movehl_ps(in, in));
// convert to floats
__m128 part = _mm_movelh_ps(in, _mm_cvtpi32_ps(in, hi));
__m128 trunc = _mm_cvtpi32_ps(part, lo);
// clear mmx state
_mm_empty();
return(trunc);
_mm_empty ();
return trunc;
# endif
#else
vec4_t r = {
v[0] > 0.0f ? floorf(v[0]) : ceil(v[0]),
v[1] > 0.0f ? floorf(v[1]) : ceil(v[1]),
v[2] > 0.0f ? floorf(v[2]) : ceil(v[2]),
v[3] > 0.0f ? floorf(v[3]) : ceil(v[3]),
};
return(r);
vec4_t r = { v[0] > 0.0f ? floorf(v[0]) : ceil(v[0]),
v[1] > 0.0f ? floorf(v[1]) : ceil(v[1]),
v[2] > 0.0f ? floorf(v[2]) : ceil(v[2]),
v[3] > 0.0f ? floorf(v[3]) : ceil(v[3]), };
return r;
#endif
}
static inline float vec4_accum(const vec4_t v)
static inline float
vec4_accum (const vec4_t v)
{
#ifdef USE_SSE
float rv;
__m128 t;
float rv;
__m128 t;
# ifdef __SSE3__
t = _mm_hadd_ps(v, v);
t = _mm_hadd_ps(t, t);
t = _mm_hadd_ps(v, v);
t = _mm_hadd_ps(t, t);
# else
t = _mm_add_ps(v, _mm_movehl_ps(v, v));
t = _mm_add_ss(t, _mm_shuffle_ps(t, t, 0x01));
t = _mm_add_ps(v, _mm_movehl_ps(v, v));
t = _mm_add_ss(t, _mm_shuffle_ps(t, t, 0x01));
# endif
_mm_store_ss(&rv, t);
return(rv);
_mm_store_ss(&rv, t);
return rv;
#else
return(v[0] + v[1] + v[2] + v[3]);
return v[0] + v[1] + v[2] + v[3];
#endif
}
static inline float vec4_dot(const vec4_t a, const vec4_t b)
static inline float
vec4_dot (const vec4_t a,
const vec4_t b)
{
#if defined(USE_SSE) && defined(__SSE4_1__)
float rv;
__m128 t = _mm_dp_ps(a, b, 0xff);
_mm_store_ss(&rv, t);
return(rv);
float rv;
__m128 t = _mm_dp_ps(a, b, 0xff);
_mm_store_ss(&rv, t);
return rv;
#else
return(vec4_accum(a * b));
return vec4_accum(a * b);
#endif
}
static inline int vec4_cmplt(const vec4_t a, const vec4_t b)
static inline int
vec4_cmplt (const vec4_t a,
const vec4_t b)
{
#ifdef USE_SSE
__m128 bits = _mm_cmplt_ps(a, b);
int val = _mm_movemask_ps(bits);
return(val != 0);
__m128 bits = _mm_cmplt_ps(a, b);
int val = _mm_movemask_ps(bits);
return val != 0;
#else
return((a[0] < b[0]) || (a[1] < b[1]) || (a[2] < b[2]) || (a[3] < b[3]));
return (a[0] < b[0]) || (a[1] < b[1]) || (a[2] < b[2]) || (a[3] < b[3]);
#endif
}
#endif
#endif /* __VEC_H__ */