Initial checkin of Pika from heckimp
This commit is contained in:
339
plug-ins/file-dds/COPYING
Normal file
339
plug-ins/file-dds/COPYING
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
21
plug-ins/file-dds/LICENSE
Normal file
21
plug-ins/file-dds/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
DDS PIKA plugin
|
||||
|
||||
Copyright (C) 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.
|
||||
*/
|
23
plug-ins/file-dds/LICENSE.nvtt
Normal file
23
plug-ins/file-dds/LICENSE.nvtt
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2009-2011 Ignacio Castano <castano@gmail.com>
|
||||
// Copyright (c) 2007-2009 NVIDIA Corporation -- Ignacio Castano <icastano@nvidia.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
29
plug-ins/file-dds/README
Normal file
29
plug-ins/file-dds/README
Normal file
@ -0,0 +1,29 @@
|
||||
DDS plugin for The PIKA
|
||||
(C) 2004-2012 Shawn Kirst <skirst@gmail.com>,
|
||||
with parts (C) 2003 Arne Reuter <homepage@arnereuter.de> where specified.
|
||||
==========================================
|
||||
|
||||
This is a plugin for PIKA version 2.4.x. It allows you to load and save
|
||||
images in Direct Draw Surface (DDS) format.
|
||||
|
||||
Features
|
||||
==========================================
|
||||
* Load/Save DDS files using DXT texture compression
|
||||
* Automatic mipmap generation on save
|
||||
* Load mipmaps into separate layers
|
||||
* Load cube map faces and volume map slices into separate layers
|
||||
* Cube and volume map saving
|
||||
* Pixel conversion selection for custom formats (RGBA4, R5G6B5, RGB10A2, etc.)
|
||||
* Load/save DDS files, optionally using DirectX texture compression (DXT)
|
||||
* Optional automatic mipmap generation when saving
|
||||
* Load mipmaps into separate layers
|
||||
* Load cube map faces and volume map slices into separate layers
|
||||
* Save cube maps and volume maps with automatic mipmap generation support
|
||||
* Save image with a custom pixel format
|
||||
* Non-power-of-two image loading and saving support with automatic mipmap generation support
|
||||
* Compliant with DirectX 10 compressed formats
|
||||
|
||||
|
||||
Installation
|
||||
==========================================
|
||||
See the file INSTALL for installation instructions
|
175
plug-ins/file-dds/README.dxt
Normal file
175
plug-ins/file-dds/README.dxt
Normal file
@ -0,0 +1,175 @@
|
||||
The following notes are from an email I received from Fabian 'ryg' Giesen. They
|
||||
should help answer some questions regarding the code found in dxt.c
|
||||
|
||||
---
|
||||
|
||||
mul8bit: This formula is equivalent to (a*b)/255 for a fairly large set of
|
||||
values (didn't bother finding out the exact bounds). It's a fairly well-known
|
||||
trick also used in other parts of the PIKA codebase (among others) and was
|
||||
first documented by Jim Blinn, I think. A good reference is his book "Dirty
|
||||
Pixels".
|
||||
|
||||
---
|
||||
|
||||
lerp_rgb: The expression computed is exactly equivalent to mul8bit(a[i],255-f)
|
||||
+ mul8bit(b[i],f) - I just verified that by brute force for -255 <= b[i]-a[i]
|
||||
<= 255 because I couldn't be bothered to find a derivation for this :) . You
|
||||
customarily use a factor between 0 and 256 include for LERPing if you can, but
|
||||
normal DXT blocks have colors placed at 1/3 and 2/3 between the two
|
||||
interpolated colors. 255 is divisible by 3, so lerp_rgb can later be used in
|
||||
eval_colors to determine the result of
|
||||
|
||||
a*(1/3) + b*(2/3) and a*(2/3) + b*(1/3)
|
||||
|
||||
exactly, which is nice :)
|
||||
|
||||
---
|
||||
|
||||
dither_block: This is just Floyd-Steinberg dithering. Distributing the error
|
||||
terms to the adjacent pixels for each source pixel is the customary variant to
|
||||
write this, but since blocks are so small, it's nearly all boundary
|
||||
cases; "gathering" the error terms per source pixel turned out to be simpler.
|
||||
|
||||
---
|
||||
|
||||
match_colors_block: This includes a few tricks. We want to map each source
|
||||
color to its nearest representable color (index), using the euclidean distance
|
||||
as a metric.
|
||||
|
||||
The obvious, brute-force way is to just compare squared distances to the 4
|
||||
representable colors for each source pixel (using, for example,
|
||||
color_distance); this requires a lot of arithmetic operations.
|
||||
|
||||
Instead, the code uses the fact that the 4 colors lie on a line in RGB space
|
||||
(only approximately in truth, since we have discrete steps). It's a well-known
|
||||
fact in geometry that if P is the closest point to the line L in 3D space, and
|
||||
Q is the point closest to P on L, then (P-Q) is orthogonal to the direction of
|
||||
L. So (in R3 at least), we can simply determine Q by projecting P onto the
|
||||
direction vector of L, which is done by the 16 dot products in the first for
|
||||
loop. Since the RGB values have discrete steps in reality, this is just an
|
||||
approximation, but a quite good one.
|
||||
|
||||
The loop after that determines where the 4 actually representable colors lie
|
||||
along the line. After that, you simply need to determine which of those 4
|
||||
values your current pixel's dot product is closest to. Instead of doing a
|
||||
bunch of comparisons per pixel, the code computes the points along the line
|
||||
at which the decision would change (that's c0pt, halfpt and c3pt). This would
|
||||
still require 3 comparisons; by testing the middle point - which is halfpt -
|
||||
first, one point is always excluded from consideration, which reduces the
|
||||
number of compares to two in all cases. No big deal, but hey, why not :)
|
||||
|
||||
Similarly, instead of dithering full RGB values, I just dither the dot product
|
||||
values. Again, by my experiments this works just as well and reduces the
|
||||
amount of work significantly.
|
||||
|
||||
---
|
||||
|
||||
optimize_colors_block: This first determines min/max/mean for r,g,b and the
|
||||
covariance matrix for the color distribution. The latter is used to determine
|
||||
the principal component (=eigenvector with largest eigenvalue) of that color
|
||||
distribution, or the direction along which the colors in the block vary most
|
||||
(in layman's terms) - the eigenvector is determined using simple power
|
||||
iteration (a standard technique). That iteration needs a seed vector; I just
|
||||
use (max_r-min_r,max_g-min_g,max_b-min_b), which works well in practice. If
|
||||
the iteration converges to a vector with very small magnitude (or zero), which
|
||||
can happen sometimes, it just defaults to an approximation of the YCbCr Y
|
||||
vector (scaled appropriately to make sure no precision is lost with the dot
|
||||
products).
|
||||
|
||||
This is then used as an initial approximation for the direction of the line
|
||||
through RGB color space that is used to select colors for that block. It
|
||||
simply uses the two most extreme points along that axis as the two colors
|
||||
stored in the block.
|
||||
|
||||
---
|
||||
|
||||
refine_block: This takes a block and a chosen set of color indices, and tries
|
||||
to determine the optimal endpoints for these indices (i.e. the full process
|
||||
is: take block, use color distribution to get rough estimate of optimal
|
||||
direction, assign color indices accordingly, use these to get better
|
||||
endpoints, assign indices again). The computation just solves a least-squares
|
||||
system to minimize the square error between the actual pixels and the
|
||||
interpolated colors (solving for the two extremal colors). The least-squares
|
||||
computation turns out to boil down to solving a 2x2 system of linear equations
|
||||
for each of the RGB color channels; the actual solution is computed using
|
||||
Cramer's rule.
|
||||
|
||||
The code is somewhat weird (especially the "prods"/"akku" thing), but that's
|
||||
just to reduce the amount of computation done (this piece of code is a hot
|
||||
spot, so it's worth it).
|
||||
|
||||
The (!yy || !xx || xx * yy == xy*xy) part checks whether the system of linear
|
||||
equations is degenerate. After pondering about this some months ago, I found
|
||||
out that the only case in which this can ever happen is when all pixels of the
|
||||
source block get mapped to the same color value. But that case can be handled
|
||||
better in any case, by just using the single-color lookup tables. I've
|
||||
attached the new version of refine_block using that observation - it both
|
||||
increases performance (a bit) and image quality, so it's pretty neat.
|
||||
|
||||
---
|
||||
|
||||
encode_alpha_block_DXT5: The only thing that shouldn't be obvious is the index
|
||||
computation. This just uses some two's complement arithmetic and bit shuffling
|
||||
to avoid computing
|
||||
|
||||
7 * (in_alpha - min_alpha) / (max_alpha - min_alpha)
|
||||
|
||||
which would be more expensive. (The extra calc with idx is just because of the
|
||||
weird DXT color numbering).
|
||||
|
||||
---
|
||||
|
||||
Some more notes on the general flow:
|
||||
|
||||
The computation without dithering is just as I explained in the part about
|
||||
refine_block:
|
||||
1. Calc initial endpoints directly from block colors
|
||||
2. Determine color indices for these endpoints
|
||||
3. Optimize endpoints given color indices
|
||||
4. Determine new color indices given optimized endpoints
|
||||
|
||||
With dithering, there's a twist: The first two steps are done using a version
|
||||
of the block dithered to colors that are representable using 16-bit 565 RGB
|
||||
values. I've found that this significantly improves visual quality with
|
||||
dithering; if you don't do this, the colors inside a block typically vary too
|
||||
little for dithering to be useful. This process decreases objective quality
|
||||
but typically looks notably better.
|
||||
|
||||
The single-color match (omatch5/omatch6) trick: If the block only contains a
|
||||
single color (or, for the improved version of refine_block, if the color
|
||||
values are sufficiently close to all map to the same index), an optimal
|
||||
solution can be used instead.
|
||||
|
||||
You normally want solid-color blocks to map to solid-color block (because
|
||||
dithering patterns are very obvious otherwise). This means that all color
|
||||
indices for the block are going to be identical, i.e. all 0, 1, 2 or 3. All-0
|
||||
is symmetrical to all-1 (with the endpoints flipped), and all-2 is symmetrical
|
||||
to all-3 (again with the endpoints flipped). So you only need to consider
|
||||
all-0 or all-2 indices for the block. Furthermore, all-0 means that the first
|
||||
endpoint specified in the block gets used for all pixels; you can get the same
|
||||
result by setting both endpoints to the same value and using index 2 for
|
||||
everything.
|
||||
|
||||
In short, you can always set all indices to 2 without sacrificing any quality
|
||||
whatsoever. For any of the color components R,G,B, you then want to determine
|
||||
5-bit or 6-bit values a and b such that
|
||||
|
||||
expand[a]*(2/3) + expand[b]*(1/3) is as close as possible to R/G/B
|
||||
|
||||
and that's exactly what's in omatch5 (for 5-bit values) and omatch6 (for 6-bit
|
||||
values).
|
||||
|
||||
If you use the 3-color+transparency mode of DXT1, you need separate versions
|
||||
for omatch5/omatch6 for this case, since the interpolated value is exactly
|
||||
halfway between the two endpoints instead of 1/3 of the way along. But I
|
||||
recommend against that mode, because even if your top-level mipmap has 1-bit
|
||||
transparency, mipmaps will have more than 2 distinct values, and the DXT mode
|
||||
is selected per texture. That's why my original code doesn't support the
|
||||
3-color mode of DXT1 at all: I don't think it's useful in practice.
|
||||
|
||||
Not sure if all of this is useful to you or not, but I guess it might make
|
||||
sense to at least put this in a separate text file or whatever, because
|
||||
otherwise it's really quite hard to see what's going on in some places.
|
||||
|
||||
Cheers,
|
||||
-Fabian "ryg" Giesen
|
7
plug-ins/file-dds/TODO
Normal file
7
plug-ins/file-dds/TODO
Normal file
@ -0,0 +1,7 @@
|
||||
TODO list for future releases of pika-dds:
|
||||
|
||||
* Add support for DX10 DDS extensions
|
||||
* BC6H and BC7 compression support
|
||||
* Volume map compression support (VTC)
|
||||
* Add support for PIKA 2.6.x GEGL for reading and writing higher precision
|
||||
pixel formats
|
58
plug-ins/file-dds/color.c
Normal file
58
plug-ins/file-dds/color.c
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* DDS PIKA 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
96
plug-ins/file-dds/color.h
Normal file
96
plug-ins/file-dds/color.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* DDS PIKA 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 __COLOR_H__
|
||||
#define __COLOR_H__
|
||||
|
||||
#include "imath.h"
|
||||
|
||||
/* sRGB encoding/decoding */
|
||||
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)
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
/* other color conversions */
|
||||
|
||||
static inline int
|
||||
rgb_to_luminance (int r, int g, int b)
|
||||
{
|
||||
/* ITU-R BT.709 luma coefficients, scaled by 256 */
|
||||
return ((r * 54 + g * 182 + b * 20) + 128) >> 8;
|
||||
}
|
||||
|
||||
static inline unsigned short
|
||||
pack_r5g6b5 (int r, int g, int b)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
return ((unsigned int)((a >> 6) & 0x003) << 30) |
|
||||
((unsigned int)((b << 2) & 0x3ff) << 20) |
|
||||
((unsigned int)((g << 2) & 0x3ff) << 10) |
|
||||
((unsigned int)((r << 2) & 0x3ff) );
|
||||
}
|
||||
|
||||
#endif /* __COLOR_H__ */
|
549
plug-ins/file-dds/dds.c
Normal file
549
plug-ins/file-dds/dds.c
Normal file
@ -0,0 +1,549 @@
|
||||
/*
|
||||
* DDS PIKA 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 "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libpika/pika.h>
|
||||
#include <libpika/pikaui.h>
|
||||
|
||||
#include <libpika/stdplugins-intl.h>
|
||||
|
||||
#include "dds.h"
|
||||
#include "ddsread.h"
|
||||
#include "ddswrite.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
#define LOAD_PROC "file-dds-load"
|
||||
#define SAVE_PROC "file-dds-save"
|
||||
|
||||
#define DECODE_YCOCG_PROC "color-decode-ycocg"
|
||||
#define DECODE_YCOCG_SCALED_PROC "color-decode-ycocg-scaled"
|
||||
#define DECODE_ALPHA_EXP_PROC "color-decode-alpha-exp"
|
||||
|
||||
|
||||
typedef struct _Dds Dds;
|
||||
typedef struct _DdsClass DdsClass;
|
||||
|
||||
struct _Dds
|
||||
{
|
||||
PikaPlugIn parent_instance;
|
||||
};
|
||||
|
||||
struct _DdsClass
|
||||
{
|
||||
PikaPlugInClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
#define DDS_TYPE (dds_get_type ())
|
||||
#define DDS (obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DDS_TYPE, Dds))
|
||||
|
||||
GType dds_get_type (void) G_GNUC_CONST;
|
||||
|
||||
static GList * dds_query_procedures (PikaPlugIn *plug_in);
|
||||
static PikaProcedure * dds_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name);
|
||||
|
||||
static PikaValueArray * dds_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
static PikaValueArray * dds_save (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
#if 0
|
||||
static PikaValueArray * dds_decode (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data);
|
||||
#endif
|
||||
|
||||
|
||||
G_DEFINE_TYPE (Dds, dds, PIKA_TYPE_PLUG_IN)
|
||||
|
||||
PIKA_MAIN (DDS_TYPE)
|
||||
DEFINE_STD_SET_I18N
|
||||
|
||||
|
||||
static void
|
||||
dds_class_init (DdsClass *klass)
|
||||
{
|
||||
PikaPlugInClass *plug_in_class = PIKA_PLUG_IN_CLASS (klass);
|
||||
|
||||
plug_in_class->query_procedures = dds_query_procedures;
|
||||
plug_in_class->create_procedure = dds_create_procedure;
|
||||
plug_in_class->set_i18n = STD_SET_I18N;
|
||||
}
|
||||
|
||||
static void
|
||||
dds_init (Dds *dds)
|
||||
{
|
||||
}
|
||||
|
||||
static GList *
|
||||
dds_query_procedures (PikaPlugIn *plug_in)
|
||||
{
|
||||
GList *list = NULL;
|
||||
|
||||
list = g_list_append (list, g_strdup (LOAD_PROC));
|
||||
list = g_list_append (list, g_strdup (SAVE_PROC));
|
||||
#if 0
|
||||
list = g_list_append (list, g_strdup (DECODE_YCOCG_PROC));
|
||||
list = g_list_append (list, g_strdup (DECODE_YCOCG_SCALED_PROC));
|
||||
list = g_list_append (list, g_strdup (DECODE_ALPHA_EXP_PROC));
|
||||
#endif
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static PikaProcedure *
|
||||
dds_create_procedure (PikaPlugIn *plug_in,
|
||||
const gchar *name)
|
||||
{
|
||||
PikaProcedure *procedure = NULL;
|
||||
|
||||
if (! strcmp (name, LOAD_PROC))
|
||||
{
|
||||
procedure = pika_load_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
dds_load, NULL, NULL);
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("DDS image"));
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Loads files in DDS image format"),
|
||||
_("Loads files in DDS image format"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Shawn Kirst",
|
||||
"Shawn Kirst",
|
||||
"2008");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
"image/dds");
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
"dds");
|
||||
pika_file_procedure_set_magics (PIKA_FILE_PROCEDURE (procedure),
|
||||
"0,string,DDS");
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "load-mipmaps",
|
||||
_("Load _mipmaps"),
|
||||
_("Load mipmaps if present"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "decode-images",
|
||||
_("Automatically decode YCoCg/AE_xp images when detected"),
|
||||
_("Decode YCoCg/AExp images when detected"),
|
||||
TRUE,
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
else if (! strcmp (name, SAVE_PROC))
|
||||
{
|
||||
procedure = pika_save_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
dds_save, NULL, NULL);
|
||||
|
||||
pika_procedure_set_image_types (procedure, "INDEXED, GRAY, RGB");
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("DDS image"));
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
"Saves files in DDS image format",
|
||||
"Saves files in DDS image format",
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Shawn Kirst",
|
||||
"Shawn Kirst",
|
||||
"2008");
|
||||
|
||||
pika_file_procedure_set_mime_types (PIKA_FILE_PROCEDURE (procedure),
|
||||
"image/dds");
|
||||
pika_file_procedure_set_extensions (PIKA_FILE_PROCEDURE (procedure),
|
||||
"dds");
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "compression-format",
|
||||
"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))",
|
||||
0, 10, DDS_COMPRESS_NONE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "mipmaps",
|
||||
"Mipmaps",
|
||||
"How to handle mipmaps (0 = No mipmaps, "
|
||||
"1 = Generate mipmaps, "
|
||||
"2 = Use existing mipmaps (layers)",
|
||||
0, 2, DDS_MIPMAP_NONE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "save-type",
|
||||
"Save type",
|
||||
"How to save the image (0 = selected layer, "
|
||||
"1 = cube map, 2 = volume map, 3 = texture array, "
|
||||
"4 = all visible layers)",
|
||||
0, 4, DDS_SAVE_SELECTED_LAYER,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "format",
|
||||
"Format",
|
||||
"Pixel format (0 = default, 1 = DDS_FORMAT_RGB8, "
|
||||
"2 = DDS_FORMAT_RGBA8, 3 = DDS_FORMAT_BGR8, "
|
||||
"4 = DDS_FORMAT_ABGR8, 5 = DDS_FORMAT_R5G6B5, "
|
||||
"6 = DDS_FORMAT_RGBA4, 7 = DDS_FORMAT_RGB5A1, "
|
||||
"8 = DDS_FORMAT_RGB10A2, 9 = DDS_FORMAT_R3G3B2, "
|
||||
"10 = DDS_FORMAT_A8, 11 = DDS_FORMAT_L8, "
|
||||
"12 = DDS_FORMAT_L8A8, 13 = DDS_FORMAT_AEXP, "
|
||||
"14 = DDS_FORMAT_YCOCG)",
|
||||
0, 14, DDS_FORMAT_DEFAULT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "flip-image",
|
||||
"Flip image vertically",
|
||||
"Flip the image vertically on export",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "transparent-color",
|
||||
"Transparent color",
|
||||
"Make an indexed color transparent",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "transparent-index",
|
||||
"Transparent index",
|
||||
"Index of transparent color or -1 to disable "
|
||||
"(for indexed images only).",
|
||||
0, 255, 0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "mipmap-filter",
|
||||
"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)",
|
||||
0, 8, DDS_MIPMAP_FILTER_DEFAULT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_INT (procedure, "mipmap-wrap",
|
||||
"Mipmap wrap",
|
||||
"Wrap mode to use when generating mipmaps "
|
||||
"(0 = default, 1 = mirror, 2 = repeat, 3 = clamp)",
|
||||
0, 3, DDS_MIPMAP_WRAP_DEFAULT,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "gamma-correct",
|
||||
"Gamma correct",
|
||||
"Use gamma correct mipmap filtering",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "srgb",
|
||||
"sRGB",
|
||||
"Use sRGB colorspace for gamma correction",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_DOUBLE (procedure, "gamma",
|
||||
"Gamma",
|
||||
"Gamma value to use for gamma correction (i.e. 2.2)",
|
||||
0.0, 10.0, 0.0,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "perceptual-metric",
|
||||
"Perceptual metric",
|
||||
"Use a perceptual error metric during compression",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_BOOLEAN (procedure, "preserve-alpha-coverage",
|
||||
"Preserve alpha coverage",
|
||||
"Preserve alpha test converage for alpha "
|
||||
"channel maps",
|
||||
FALSE,
|
||||
G_PARAM_READWRITE);
|
||||
|
||||
PIKA_PROC_ARG_DOUBLE (procedure, "alpha-test-threshold",
|
||||
"Alpha test threshold",
|
||||
"Alpha test threshold value for which alpha test "
|
||||
"converage should be preserved",
|
||||
0.0, 1.0, 0.5,
|
||||
G_PARAM_READWRITE);
|
||||
}
|
||||
#if 0
|
||||
else if (! strcmp (name, DECODE_YCOCG_PROC))
|
||||
{
|
||||
procedure = pika_image_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
dds_decode, NULL, NULL);
|
||||
|
||||
pika_procedure_set_image_types (procedure, "RGBA");
|
||||
pika_procedure_set_sensitivity_mask (procedure,
|
||||
PIKA_PROCEDURE_SENSITIVE_DRAWABLE);
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("Decode YCoCg"));
|
||||
/* pika_procedure_add_menu_path (procedure, "<Image>/Filters/Colors"); */
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Converts YCoCg encoded pixels to RGB"),
|
||||
_("Converts YCoCg encoded pixels to RGB"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Shawn Kirst",
|
||||
"Shawn Kirst",
|
||||
"2008");
|
||||
}
|
||||
else if (! strcmp (name, DECODE_YCOCG_SCALED_PROC))
|
||||
{
|
||||
procedure = pika_image_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
dds_decode, NULL, NULL);
|
||||
|
||||
pika_procedure_set_image_types (procedure, "RGBA");
|
||||
pika_procedure_set_sensitivity_mask (procedure,
|
||||
PIKA_PROCEDURE_SENSITIVE_DRAWABLE);
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("Decode YCoCg (scaled)"));
|
||||
/* pika_procedure_add_menu_path (procedure, "<Image>/Filters/Colors"); */
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Converts YCoCg (scaled) encoded "
|
||||
"pixels to RGB"),
|
||||
_("Converts YCoCg (scaled) encoded "
|
||||
"pixels to RGB"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Shawn Kirst",
|
||||
"Shawn Kirst",
|
||||
"2008");
|
||||
}
|
||||
else if (! strcmp (name, DECODE_ALPHA_EXP_PROC))
|
||||
{
|
||||
procedure = pika_image_procedure_new (plug_in, name,
|
||||
PIKA_PDB_PROC_TYPE_PLUGIN,
|
||||
dds_decode, NULL, NULL);
|
||||
|
||||
pika_procedure_set_image_types (procedure, "RGBA");
|
||||
pika_procedure_set_sensitivity_mask (procedure,
|
||||
PIKA_PROCEDURE_SENSITIVE_DRAWABLE);
|
||||
|
||||
pika_procedure_set_menu_label (procedure, _("Decode Alpha exponent"));
|
||||
/* pika_procedure_add_menu_path (procedure, "<Image>/Filters/Colors"); */
|
||||
|
||||
pika_procedure_set_documentation (procedure,
|
||||
_("Converts alpha exponent encoded "
|
||||
"pixels to RGB",
|
||||
_("Converts alpha exponent encoded "
|
||||
"pixels to RGB"),
|
||||
name);
|
||||
pika_procedure_set_attribution (procedure,
|
||||
"Shawn Kirst",
|
||||
"Shawn Kirst",
|
||||
"2008");
|
||||
}
|
||||
#endif
|
||||
|
||||
return procedure;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
dds_load (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaProcedureConfig *config;
|
||||
PikaValueArray *return_vals;
|
||||
PikaPDBStatusType status;
|
||||
PikaImage *image;
|
||||
GError *error = NULL;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
config = pika_procedure_create_config (procedure);
|
||||
pika_procedure_config_begin_run (config, NULL, run_mode, args);
|
||||
|
||||
status = read_dds (file, &image, run_mode == PIKA_RUN_INTERACTIVE,
|
||||
procedure, G_OBJECT (config), &error);
|
||||
|
||||
pika_procedure_config_end_run (config, status);
|
||||
g_object_unref (config);
|
||||
|
||||
if (status != PIKA_PDB_SUCCESS)
|
||||
return pika_procedure_new_return_values (procedure, status, error);
|
||||
|
||||
return_vals = pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_SUCCESS,
|
||||
NULL);
|
||||
|
||||
PIKA_VALUES_SET_IMAGE (return_vals, 1, image);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static PikaValueArray *
|
||||
dds_save (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
GFile *file,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
PikaProcedureConfig *config;
|
||||
PikaPDBStatusType status = PIKA_PDB_SUCCESS;
|
||||
PikaExportReturn export = PIKA_EXPORT_CANCEL;
|
||||
GError *error = NULL;
|
||||
gdouble gamma;
|
||||
|
||||
gegl_init (NULL, NULL);
|
||||
|
||||
config = pika_procedure_create_config (procedure);
|
||||
pika_procedure_config_begin_run (config, NULL, run_mode, args);
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case PIKA_RUN_INTERACTIVE:
|
||||
case PIKA_RUN_WITH_LAST_VALS:
|
||||
pika_ui_init ("dds");
|
||||
|
||||
export = pika_export_image (&image, &n_drawables, &drawables, "DDS",
|
||||
PIKA_EXPORT_CAN_HANDLE_RGB |
|
||||
PIKA_EXPORT_CAN_HANDLE_GRAY |
|
||||
PIKA_EXPORT_CAN_HANDLE_INDEXED |
|
||||
PIKA_EXPORT_CAN_HANDLE_ALPHA |
|
||||
PIKA_EXPORT_CAN_HANDLE_LAYERS);
|
||||
|
||||
if (export == PIKA_EXPORT_CANCEL)
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_CANCEL,
|
||||
NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
g_object_get (config,
|
||||
"gamma", &gamma,
|
||||
NULL);
|
||||
|
||||
/* pika_gamma () got removed and was always returning 2.2 anyway.
|
||||
* XXX Review this piece of code if we expect gamma value could be
|
||||
* parameterized.
|
||||
*/
|
||||
if (gamma < 1e-04f)
|
||||
g_object_set (config,
|
||||
"gamma", 2.2,
|
||||
NULL);
|
||||
|
||||
/* TODO: support multiple-layers selection, especially as DDS has
|
||||
* DDS_SAVE_SELECTED_LAYER option support.
|
||||
*/
|
||||
status = write_dds (file, image, drawables[0],
|
||||
run_mode == PIKA_RUN_INTERACTIVE,
|
||||
procedure, G_OBJECT (config),
|
||||
export == PIKA_EXPORT_EXPORT);
|
||||
|
||||
if (export == PIKA_EXPORT_EXPORT)
|
||||
{
|
||||
pika_image_delete (image);
|
||||
g_free (drawables);
|
||||
}
|
||||
|
||||
pika_procedure_config_end_run (config, status);
|
||||
g_object_unref (config);
|
||||
|
||||
return pika_procedure_new_return_values (procedure, status, error);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static PikaValueArray *
|
||||
dds_decode (PikaProcedure *procedure,
|
||||
PikaRunMode run_mode,
|
||||
PikaImage *image,
|
||||
gint n_drawables,
|
||||
PikaDrawable **drawables,
|
||||
const PikaValueArray *args,
|
||||
gpointer run_data)
|
||||
{
|
||||
const gchar *name = pika_procedure_get_name (procedure);
|
||||
PikaDrawable *drawable,
|
||||
|
||||
if (n_drawables != 1)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
g_set_error (&error, PIKA_PLUG_IN_ERROR, 0,
|
||||
_("Procedure '%s' only works with one drawable."),
|
||||
name);
|
||||
|
||||
return pika_procedure_new_return_values (procedure,
|
||||
PIKA_PDB_EXECUTION_ERROR,
|
||||
error);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawable = drawables[0];
|
||||
}
|
||||
|
||||
if (! strcmp (name, DECODE_YCOCG_PROC))
|
||||
{
|
||||
decode_ycocg_image (drawable, TRUE);
|
||||
}
|
||||
else if (! strcmp (name, DECODE_YCOCG_SCALED_PROC))
|
||||
{
|
||||
decode_ycocg_scaled_image (drawable, TRUE);
|
||||
}
|
||||
else if (! strcmp (name, DECODE_ALPHA_EXP_PROC))
|
||||
{
|
||||
decode_alpha_exp_image (drawable, TRUE);
|
||||
}
|
||||
|
||||
if (run_mode != PIKA_RUN_NONINTERACTIVE)
|
||||
pika_displays_flush ();
|
||||
|
||||
return pika_procedure_new_return_values (procedure, PIKA_PDB_SUCCESS, NULL);
|
||||
}
|
||||
#endif
|
337
plug-ins/file-dds/dds.h
Normal file
337
plug-ins/file-dds/dds.h
Normal file
@ -0,0 +1,337 @@
|
||||
/*
|
||||
* DDS PIKA 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 __DDS_H__
|
||||
#define __DDS_H__
|
||||
|
||||
#define DDS_PLUGIN_VERSION_MAJOR 3
|
||||
#define DDS_PLUGIN_VERSION_MINOR 9
|
||||
#define DDS_PLUGIN_VERSION_REVISION 92
|
||||
|
||||
#define DDS_PLUGIN_VERSION \
|
||||
((guint) (DDS_PLUGIN_VERSION_MAJOR << 16) | \
|
||||
(guint) (DDS_PLUGIN_VERSION_MINOR << 8) | \
|
||||
(guint) (DDS_PLUGIN_VERSION_REVISION))
|
||||
|
||||
|
||||
#define FOURCC(a, b, c, d) \
|
||||
((guint) ((guint)(a) ) | \
|
||||
((guint)(b) << 8) | \
|
||||
((guint)(c) << 16) | \
|
||||
((guint)(d) << 24))
|
||||
|
||||
|
||||
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_COMPRESSION_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DDS_SAVE_SELECTED_LAYER = 0,
|
||||
DDS_SAVE_CUBEMAP,
|
||||
DDS_SAVE_VOLUMEMAP,
|
||||
DDS_SAVE_ARRAY,
|
||||
DDS_SAVE_VISIBLE_LAYERS,
|
||||
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_TYPE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
#define DDS_HEADERSIZE 128
|
||||
#define DDS_HEADERSIZE_DX10 20
|
||||
|
||||
#define DDSD_CAPS 0x00000001
|
||||
#define DDSD_HEIGHT 0x00000002
|
||||
#define DDSD_WIDTH 0x00000004
|
||||
#define DDSD_PITCH 0x00000008
|
||||
#define DDSD_PIXELFORMAT 0x00001000
|
||||
#define DDSD_MIPMAPCOUNT 0x00020000
|
||||
#define DDSD_LINEARSIZE 0x00080000
|
||||
#define DDSD_DEPTH 0x00800000
|
||||
|
||||
#define DDPF_ALPHAPIXELS 0x00000001
|
||||
#define DDPF_ALPHA 0x00000002
|
||||
#define DDPF_FOURCC 0x00000004
|
||||
#define DDPF_PALETTEINDEXED8 0x00000020
|
||||
#define DDPF_RGB 0x00000040
|
||||
#define DDPF_LUMINANCE 0x00020000
|
||||
#define DDPF_NORMAL 0x80000000 // nvidia specific
|
||||
|
||||
#define DDSCAPS_COMPLEX 0x00000008
|
||||
#define DDSCAPS_TEXTURE 0x00001000
|
||||
#define DDSCAPS_MIPMAP 0x00400000
|
||||
|
||||
#define DDSCAPS2_CUBEMAP 0x00000200
|
||||
#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
|
||||
#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
|
||||
#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
|
||||
#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
|
||||
#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
|
||||
#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
|
||||
#define DDSCAPS2_CUBEMAP_ALL_FACES \
|
||||
(DDSCAPS2_CUBEMAP_POSITIVEX | DDSCAPS2_CUBEMAP_NEGATIVEX | \
|
||||
DDSCAPS2_CUBEMAP_POSITIVEY | DDSCAPS2_CUBEMAP_NEGATIVEY | \
|
||||
DDSCAPS2_CUBEMAP_POSITIVEZ | DDSCAPS2_CUBEMAP_NEGATIVEZ)
|
||||
|
||||
#define DDSCAPS2_VOLUME 0x00200000
|
||||
|
||||
#define D3D10_RESOURCE_MISC_TEXTURECUBE 0x04
|
||||
#define D3D10_RESOURCE_DIMENSION_BUFFER 1
|
||||
#define D3D10_RESOURCE_DIMENSION_TEXTURE1D 2
|
||||
#define D3D10_RESOURCE_DIMENSION_TEXTURE2D 3
|
||||
#define D3D10_RESOURCE_DIMENSION_TEXTURE3D 4
|
||||
|
||||
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;
|
||||
} dds_pixel_format_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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 "PIKA"
|
||||
unsigned int magic2; // FOURCC "-DDS"
|
||||
unsigned int version;
|
||||
unsigned int extra_fourcc;
|
||||
} pika_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;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DXGI_FORMAT dxgiFormat;
|
||||
unsigned int resourceDimension;
|
||||
unsigned int miscFlag;
|
||||
unsigned int arraySize;
|
||||
unsigned int reserved;
|
||||
} dds_header_dx10_t;
|
||||
|
||||
#endif /* __DDS_H__ */
|
1533
plug-ins/file-dds/ddsread.c
Normal file
1533
plug-ins/file-dds/ddsread.c
Normal file
File diff suppressed because it is too large
Load Diff
33
plug-ins/file-dds/ddsread.h
Normal file
33
plug-ins/file-dds/ddsread.h
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* DDS PIKA 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 __DDSREAD_H__
|
||||
#define __DDSREAD_H__
|
||||
|
||||
|
||||
extern PikaPDBStatusType read_dds (GFile *file,
|
||||
PikaImage **image,
|
||||
gboolean interactive,
|
||||
PikaProcedure *procedure,
|
||||
GObject *config,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __DDSREAD_H__ */
|
2204
plug-ins/file-dds/ddswrite.c
Normal file
2204
plug-ins/file-dds/ddswrite.c
Normal file
File diff suppressed because it is too large
Load Diff
34
plug-ins/file-dds/ddswrite.h
Normal file
34
plug-ins/file-dds/ddswrite.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* DDS PIKA 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 __DDSWRITE_H__
|
||||
#define __DDSWRITE_H__
|
||||
|
||||
|
||||
extern PikaPDBStatusType write_dds (GFile *file,
|
||||
PikaImage *image,
|
||||
PikaDrawable *drawable,
|
||||
gboolean interactive,
|
||||
PikaProcedure *procedure,
|
||||
GObject *config,
|
||||
gboolean is_duplicate_image);
|
||||
|
||||
|
||||
#endif /* __DDSWRITE_H__ */
|
1526
plug-ins/file-dds/dxt.c
Normal file
1526
plug-ins/file-dds/dxt.c
Normal file
File diff suppressed because it is too large
Load Diff
49
plug-ins/file-dds/dxt.h
Normal file
49
plug-ins/file-dds/dxt.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* DDS PIKA 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 __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_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);
|
||||
|
||||
#endif /* __DXT_H__ */
|
216
plug-ins/file-dds/dxt_tables.h
Normal file
216
plug-ins/file-dds/dxt_tables.h
Normal file
@ -0,0 +1,216 @@
|
||||
#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,
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
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},
|
||||
};
|
||||
|
||||
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},
|
||||
};
|
||||
|
||||
#endif /* __DXT_TABLES_H__ */
|
69
plug-ins/file-dds/endian_rw.h
Normal file
69
plug-ins/file-dds/endian_rw.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* DDS PIKA 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__ */
|
77
plug-ins/file-dds/imath.h
Normal file
77
plug-ins/file-dds/imath.h
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* DDS PIKA 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 __IMATH_H__
|
||||
#define __IMATH_H__
|
||||
|
||||
#ifndef MIN
|
||||
# ifdef __GNUC__
|
||||
# define MIN(a, b) ({typeof(a) _a=(a); typeof(b) _b=(b); _a < _b ? _a : _b;})
|
||||
# else
|
||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# ifdef __GNUC__
|
||||
# define MAX(a, b) ({typeof(a) _a=(a); typeof(b) _b=(b); _a > _b ? _a : _b;})
|
||||
# else
|
||||
# define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define IS_POW2(x) (!((x) & ((x) - 1)))
|
||||
#define IS_MUL4(x) (((x) & 3) == 0)
|
||||
|
||||
/* 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)
|
||||
{
|
||||
int t = a * b + 128;
|
||||
|
||||
return (t + (t >> 8)) >> 8;
|
||||
}
|
||||
|
||||
static inline int
|
||||
blerp (int a,
|
||||
int b,
|
||||
int x)
|
||||
{
|
||||
return a + mul8bit(b - a, 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;
|
||||
}
|
||||
|
||||
#endif /* __IMATH_H__ */
|
36
plug-ins/file-dds/meson.build
Normal file
36
plug-ins/file-dds/meson.build
Normal file
@ -0,0 +1,36 @@
|
||||
plugin_name = 'file-dds'
|
||||
|
||||
plugin_sources = [
|
||||
'dds.c',
|
||||
'color.c',
|
||||
'ddsread.c',
|
||||
'ddswrite.c',
|
||||
'dxt.c',
|
||||
'mipmap.c',
|
||||
'misc.c',
|
||||
]
|
||||
|
||||
if platform_windows
|
||||
plugin_sources += windows.compile_resources(
|
||||
pika_plugins_rc,
|
||||
args: [
|
||||
'--define', 'ORIGINALFILENAME_STR="@0@"'.format(plugin_name+'.exe'),
|
||||
'--define', 'INTERNALNAME_STR="@0@"' .format(plugin_name),
|
||||
'--define', 'TOP_SRCDIR="@0@"' .format(meson.project_source_root()),
|
||||
],
|
||||
include_directories: [
|
||||
rootInclude, appInclude,
|
||||
],
|
||||
)
|
||||
endif
|
||||
|
||||
executable(plugin_name,
|
||||
plugin_sources,
|
||||
dependencies: [
|
||||
libpikaui_dep,
|
||||
math,
|
||||
openmp,
|
||||
],
|
||||
install: true,
|
||||
install_dir: pikaplugindir / 'plug-ins' / plugin_name,
|
||||
)
|
1132
plug-ins/file-dds/mipmap.c
Normal file
1132
plug-ins/file-dds/mipmap.c
Normal file
File diff suppressed because it is too large
Load Diff
75
plug-ins/file-dds/mipmap.h
Normal file
75
plug-ins/file-dds/mipmap.h
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* DDS PIKA 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 __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 /* __MIPMAP_H__ */
|
261
plug-ins/file-dds/misc.c
Normal file
261
plug-ins/file-dds/misc.c
Normal file
@ -0,0 +1,261 @@
|
||||
/*
|
||||
* DDS PIKA 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 <libpika/pika.h>
|
||||
#include "misc.h"
|
||||
|
||||
static inline float
|
||||
saturate (float a)
|
||||
{
|
||||
if(a < 0) a = 0;
|
||||
if(a > 1) a = 1;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
void
|
||||
decode_ycocg_image (PikaDrawable *drawable,
|
||||
gboolean shadow)
|
||||
{
|
||||
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;
|
||||
|
||||
buffer = pika_drawable_get_buffer (drawable);
|
||||
|
||||
if (shadow)
|
||||
{
|
||||
sbuffer = pika_drawable_get_shadow_buffer (drawable);
|
||||
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);
|
||||
|
||||
pika_progress_init ("Decoding YCoCg 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;
|
||||
|
||||
/* convert YCoCg to RGB */
|
||||
Co -= offset;
|
||||
Cg -= offset;
|
||||
|
||||
R = saturate(Y + Co - Cg);
|
||||
G = saturate(Y + Cg);
|
||||
B = saturate(Y - Co - Cg);
|
||||
|
||||
/* copy new alpha from blue */
|
||||
data[4 * i + 3] = data[4 * i + 2];
|
||||
|
||||
data[4 * i + 0] = (unsigned char)(R * 255.0f);
|
||||
data[4 * i + 1] = (unsigned char)(G * 255.0f);
|
||||
data[4 * i + 2] = (unsigned char)(B * 255.0f);
|
||||
|
||||
if ((i & 0x7fff) == 0)
|
||||
pika_progress_update ((float)i / (float)num_pixels);
|
||||
}
|
||||
|
||||
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
|
||||
GEGL_AUTO_ROWSTRIDE);
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
gegl_buffer_flush (buffer);
|
||||
|
||||
if (shadow)
|
||||
pika_drawable_merge_shadow (drawable, TRUE);
|
||||
|
||||
pika_drawable_update (drawable, 0, 0, w, h);
|
||||
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
decode_ycocg_scaled_image (PikaDrawable *drawable,
|
||||
gboolean shadow)
|
||||
{
|
||||
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;
|
||||
|
||||
buffer = pika_drawable_get_buffer (drawable);
|
||||
|
||||
if (shadow)
|
||||
{
|
||||
sbuffer = pika_drawable_get_shadow_buffer (drawable);
|
||||
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);
|
||||
|
||||
pika_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;
|
||||
s = (float)data[4 * i + 2] / 255.0f;
|
||||
|
||||
/* convert YCoCg to RGB */
|
||||
s = 1.0f / ((255.0f / 8.0f) * s + 1.0f);
|
||||
|
||||
Co = (Co - offset) * s;
|
||||
Cg = (Cg - offset) * s;
|
||||
|
||||
R = saturate(Y + Co - Cg);
|
||||
G = saturate(Y + Cg);
|
||||
B = saturate(Y - Co - Cg);
|
||||
|
||||
data[4 * i + 0] = (unsigned char)(R * 255.0f);
|
||||
data[4 * i + 1] = (unsigned char)(G * 255.0f);
|
||||
data[4 * i + 2] = (unsigned char)(B * 255.0f);
|
||||
|
||||
/* set alpha to 1 */
|
||||
data[4 * i + 3] = 255;
|
||||
|
||||
if ((i & 0x7fff) == 0)
|
||||
pika_progress_update ((float)i / (float)num_pixels);
|
||||
}
|
||||
|
||||
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
|
||||
GEGL_AUTO_ROWSTRIDE);
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
gegl_buffer_flush (buffer);
|
||||
|
||||
if (shadow)
|
||||
pika_drawable_merge_shadow (drawable, TRUE);
|
||||
|
||||
pika_drawable_update (drawable, 0, 0, w, h);
|
||||
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
decode_alpha_exp_image (PikaDrawable *drawable,
|
||||
gboolean shadow)
|
||||
{
|
||||
GeglBuffer *buffer, *sbuffer;
|
||||
const Babl *format;
|
||||
unsigned char *data;
|
||||
unsigned int i, w, h, num_pixels;
|
||||
int R, G, B, A;
|
||||
|
||||
buffer = pika_drawable_get_buffer (drawable);
|
||||
|
||||
if (shadow)
|
||||
{
|
||||
sbuffer = pika_drawable_get_shadow_buffer (drawable);
|
||||
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);
|
||||
|
||||
pika_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];
|
||||
A = data[4 * i + 3];
|
||||
|
||||
R = (R * A + 1) >> 8;
|
||||
G = (G * A + 1) >> 8;
|
||||
B = (B * A + 1) >> 8;
|
||||
A = 255;
|
||||
|
||||
data[4 * i + 0] = R;
|
||||
data[4 * i + 1] = G;
|
||||
data[4 * i + 2] = B;
|
||||
data[4 * i + 3] = A;
|
||||
|
||||
if ((i & 0x7fff) == 0)
|
||||
pika_progress_update ((float)i / (float)num_pixels);
|
||||
}
|
||||
|
||||
gegl_buffer_set (buffer, GEGL_RECTANGLE(0, 0, w, h), 0, format, data,
|
||||
GEGL_AUTO_ROWSTRIDE);
|
||||
|
||||
pika_progress_update (1.0);
|
||||
|
||||
gegl_buffer_flush (buffer);
|
||||
|
||||
if (shadow)
|
||||
pika_drawable_merge_shadow (drawable, TRUE);
|
||||
|
||||
pika_drawable_update (drawable, 0, 0, w, h);
|
||||
|
||||
g_free (data);
|
||||
|
||||
g_object_unref (buffer);
|
||||
}
|
31
plug-ins/file-dds/misc.h
Normal file
31
plug-ins/file-dds/misc.h
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* DDS PIKA 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 __MISC_H__
|
||||
#define __MISC_H__
|
||||
|
||||
void decode_ycocg_image (PikaDrawable *drawable,
|
||||
gboolean shadow);
|
||||
void decode_ycocg_scaled_image (PikaDrawable *drawable,
|
||||
gboolean shadow);
|
||||
void decode_alpha_exp_image (PikaDrawable *drawable,
|
||||
gboolean shadow);
|
||||
|
||||
#endif /* __MISC_H__ */
|
245
plug-ins/file-dds/vec.h
Normal file
245
plug-ins/file-dds/vec.h
Normal file
@ -0,0 +1,245 @@
|
||||
/*
|
||||
* DDS PIKA 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 __VEC_H__
|
||||
#define __VEC_H__
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __SSE__
|
||||
#define USE_SSE 1
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSE
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
||||
#include "imath.h"
|
||||
|
||||
typedef float vec4_t __attribute__((vector_size(16)));
|
||||
typedef float sym3x3_t[6];
|
||||
|
||||
#define VEC4_CONST4(x, y, z, w) {x, y, z, w}
|
||||
#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)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_setr_ps(x, y, z, w);
|
||||
#else
|
||||
vec4_t v = { x, y, z, w };
|
||||
return v;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_set1 (float f)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_set1_ps(f);
|
||||
#else
|
||||
vec4_t v = { f, f, f, f };
|
||||
return v;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_zero (void)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_setzero_ps();
|
||||
#else
|
||||
vec4_t v = { 0, 0, 0, 0 };
|
||||
return v;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
vec4_store (float *f,
|
||||
const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
_mm_store_ps (f, v);
|
||||
#else
|
||||
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)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_shuffle_ps(v, v, 0x00);
|
||||
#else
|
||||
vec4_t r = { v[0], v[0], v[0], v[0] };
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_splaty (const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_shuffle_ps(v, v, 0x55);
|
||||
#else
|
||||
vec4_t r = { v[1], v[1], v[1], v[1] };
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_splatz (const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_shuffle_ps(v, v, 0xaa);
|
||||
#else
|
||||
vec4_t r = { v[2], v[2], v[2], v[2] };
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_splatw (const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
return _mm_shuffle_ps(v, v, 0xff);
|
||||
#else
|
||||
vec4_t r = { v[3], v[3], v[3], v[3] };
|
||||
return r;
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
#else
|
||||
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)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
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]));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_max (const vec4_t a,
|
||||
const vec4_t b)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
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]));
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline vec4_t
|
||||
vec4_trunc (const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
# ifdef __SSE4_1__
|
||||
return _mm_round_ps(v, _MM_FROUND_TRUNC);
|
||||
# elif defined(__SSE2__)
|
||||
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);
|
||||
// clear mmx state
|
||||
_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;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline float
|
||||
vec4_accum (const vec4_t v)
|
||||
{
|
||||
#ifdef USE_SSE
|
||||
float rv;
|
||||
__m128 t;
|
||||
# ifdef __SSE3__
|
||||
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));
|
||||
# endif
|
||||
_mm_store_ss(&rv, t);
|
||||
return rv;
|
||||
#else
|
||||
return v[0] + v[1] + v[2] + v[3];
|
||||
#endif
|
||||
}
|
||||
|
||||
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;
|
||||
#else
|
||||
return vec4_accum(a * b);
|
||||
#endif
|
||||
}
|
||||
|
||||
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;
|
||||
#else
|
||||
return (a[0] < b[0]) || (a[1] < b[1]) || (a[2] < b[2]) || (a[3] < b[3]);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* __VEC_H__ */
|
Reference in New Issue
Block a user