From b50c8b1fdd4ad2cb4f24b97409684e9964c04504 Mon Sep 17 00:00:00 2001 From: zilmar Date: Wed, 26 Apr 2017 20:23:36 +1000 Subject: [PATCH] [Video] Update headers --- Source/Project64-video/3dmath.cpp | 52 +- Source/Project64-video/3dmath.h | 60 +- Source/Project64-video/Android.cpp | 19 +- Source/Project64-video/CRC.cpp | 58 +- Source/Project64-video/CRC.h | 57 +- Source/Project64-video/Combine.cpp | 52 +- Source/Project64-video/Combine.h | 51 +- Source/Project64-video/Config.cpp | 59 +- Source/Project64-video/Config.h | 56 +- Source/Project64-video/Debugger.cpp | 52 +- Source/Project64-video/Debugger.h | 54 +- Source/Project64-video/DepthBufferRender.cpp | 474 +- Source/Project64-video/DepthBufferRender.h | 59 +- Source/Project64-video/Ext_TxFilter.cpp | 35 +- Source/Project64-video/Ext_TxFilter.h | 34 +- Source/Project64-video/FBtoScreen.cpp | 57 +- Source/Project64-video/FBtoScreen.h | 76 +- Source/Project64-video/Gfx_1.3.h | 79 +- Source/Project64-video/Main.cpp | 52 +- Source/Project64-video/MiClWr16b.h | 51 +- Source/Project64-video/MiClWr32b.h | 56 +- Source/Project64-video/MiClWr8b.h | 51 +- .../Renderer/OGLEScombiner.cpp | 33 +- .../Renderer/OGLESgeometry.cpp | 32 +- .../Renderer/OGLESglitchmain.cpp | 32 +- .../Renderer/OGLEStextures.cpp | 33 +- .../Renderer/OGLESwrappers.cpp | 32 +- .../Project64-video/Renderer/OGLESwrappers.h | 13 + .../Project64-video/Renderer/OGLcombiner.cpp | 13 + .../Project64-video/Renderer/OGLgeometry.cpp | 13 + .../Renderer/OGLglitchmain.cpp | 13 + .../Project64-video/Renderer/OGLtextures.cpp | 13 + Source/Project64-video/Renderer/glitchmain.h | 17 +- Source/Project64-video/ScreenResolution.cpp | 4 +- Source/Project64-video/ScreenResolution.h | 4 +- Source/Project64-video/Settings.cpp | 10 + Source/Project64-video/Settings.h | 86 +- Source/Project64-video/SettingsID.h | 4 +- Source/Project64-video/TexBuffer.cpp | 57 +- Source/Project64-video/TexBuffer.h | 57 +- Source/Project64-video/TexCache.cpp | 51 +- Source/Project64-video/TexCache.h | 52 +- Source/Project64-video/TexConv.h | 52 +- Source/Project64-video/TexLoad.h | 51 +- Source/Project64-video/TexLoad16b.h | 51 +- Source/Project64-video/TexLoad32b.h | 51 +- Source/Project64-video/TexLoad4b.h | 51 +- Source/Project64-video/TexLoad8b.h | 51 +- Source/Project64-video/TexMod.h | 52 +- Source/Project64-video/TexModCI.h | 56 +- .../TextureEnhancer/Ext_TxFilter.h | 194 +- .../TextureEnhancer/TextureFilters.cpp | 1212 ++- .../TextureEnhancer/TextureFilters.h | 44 +- .../TextureEnhancer/TextureFilters_2xsai.cpp | 120 +- .../TextureEnhancer/TextureFilters_hq2x.cpp | 1534 +-- .../TextureEnhancer/TextureFilters_hq2x.h | 3765 +++---- .../TextureEnhancer/TextureFilters_hq4x.cpp | 740 +- .../TextureEnhancer/TextureFilters_hq4x.h | 8683 ++++++++--------- .../TextureEnhancer/TextureFilters_lq2x.h | 2626 ++--- .../TextureEnhancer/TxCache.cpp | 100 +- .../Project64-video/TextureEnhancer/TxCache.h | 93 +- .../Project64-video/TextureEnhancer/TxDbg.cpp | 38 +- .../Project64-video/TextureEnhancer/TxDbg.h | 53 +- .../TextureEnhancer/TxFilter.cpp | 126 +- .../TextureEnhancer/TxFilter.h | 113 +- .../TextureEnhancer/TxFilterExport.cpp | 143 +- .../TextureEnhancer/TxHiResCache.cpp | 585 +- .../TextureEnhancer/TxHiResCache.h | 45 +- .../TextureEnhancer/TxImage.cpp | 1300 ++- .../Project64-video/TextureEnhancer/TxImage.h | 130 +- .../TextureEnhancer/TxInternal.h | 35 +- .../TextureEnhancer/TxQuantize.cpp | 3492 ++++--- .../TextureEnhancer/TxQuantize.h | 128 +- .../TextureEnhancer/TxReSample.cpp | 631 +- .../TextureEnhancer/TxReSample.h | 55 +- .../TextureEnhancer/TxTexCache.cpp | 42 +- .../TextureEnhancer/TxTexCache.h | 45 +- .../TextureEnhancer/TxUtil.cpp | 722 +- .../Project64-video/TextureEnhancer/TxUtil.h | 148 +- .../Project64-video/TextureEnhancer/bldno.h | 0 .../TextureEnhancer/tc-1.1+/dxtn.c | 890 +- .../TextureEnhancer/tc-1.1+/dxtn.h | 74 +- .../TextureEnhancer/tc-1.1+/fxt1.c | 1588 ++- .../TextureEnhancer/tc-1.1+/fxt1.h | 47 +- .../TextureEnhancer/tc-1.1+/internal.h | 54 +- .../TextureEnhancer/tc-1.1+/texstore.c | 127 +- .../TextureEnhancer/tc-1.1+/types.h | 14 + .../TextureEnhancer/tc-1.1+/wrapper.c | 124 +- Source/Project64-video/Util.cpp | 52 +- Source/Project64-video/Util.h | 63 +- Source/Project64-video/Version.h | 38 +- Source/Project64-video/rdp.cpp | 52 +- Source/Project64-video/rdp.h | 56 +- Source/Project64-video/trace.cpp | 10 + Source/Project64-video/trace.h | 10 + Source/Project64-video/turbo3D.h | 58 +- Source/Project64-video/ucode.h | 52 +- Source/Project64-video/ucode00.h | 53 +- Source/Project64-video/ucode01.h | 56 +- Source/Project64-video/ucode02.h | 53 +- Source/Project64-video/ucode03.h | 56 +- Source/Project64-video/ucode04.h | 56 +- Source/Project64-video/ucode05.h | 52 +- Source/Project64-video/ucode06.h | 54 +- Source/Project64-video/ucode07.h | 58 +- Source/Project64-video/ucode08.h | 56 +- Source/Project64-video/ucode09.h | 56 +- Source/Project64-video/ucode09rdp.h | 56 +- Source/Project64-video/ucodeFB.h | 56 +- 109 files changed, 16009 insertions(+), 17482 deletions(-) delete mode 100644 Source/Project64-video/TextureEnhancer/bldno.h diff --git a/Source/Project64-video/3dmath.cpp b/Source/Project64-video/3dmath.cpp index 9d0b1f329..4e2e4c5a0 100644 --- a/Source/Project64-video/3dmath.cpp +++ b/Source/Project64-video/3dmath.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "Gfx_1.3.h" extern "C" { #ifndef NOSSE diff --git a/Source/Project64-video/3dmath.h b/Source/Project64-video/3dmath.h index 502bd5a99..2b2dfb67b 100644 --- a/Source/Project64-video/3dmath.h +++ b/Source/Project64-video/3dmath.h @@ -1,54 +1,28 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ void calc_light (VERTEX *v); void calc_linear (VERTEX *v); void calc_sphere (VERTEX *v); void math_init(); -typedef void (*MULMATRIX)(float m1[4][4],float m2[4][4],float r[4][4]); +typedef void(*MULMATRIX)(float m1[4][4], float m2[4][4], float r[4][4]); extern MULMATRIX MulMatrices; -typedef void (*TRANSFORMVECTOR)(float *src,float *dst,float mat[4][4]); +typedef void(*TRANSFORMVECTOR)(float *src, float *dst, float mat[4][4]); extern TRANSFORMVECTOR TransformVector; extern TRANSFORMVECTOR InverseTransformVector; -typedef float (*DOTPRODUCT)(register float *v1, register float *v2); +typedef float(*DOTPRODUCT)(register float *v1, register float *v2); extern DOTPRODUCT DotProduct; -typedef void (*NORMALIZEVECTOR)(float *v); +typedef void(*NORMALIZEVECTOR)(float *v); extern NORMALIZEVECTOR NormalizeVector; diff --git a/Source/Project64-video/Android.cpp b/Source/Project64-video/Android.cpp index d73ed3000..e20eaa8f3 100644 --- a/Source/Project64-video/Android.cpp +++ b/Source/Project64-video/Android.cpp @@ -1,12 +1,13 @@ -/**************************************************************************** -* * -* Project 64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * ****************************************************************************/ #ifdef ANDROID #include diff --git a/Source/Project64-video/CRC.cpp b/Source/Project64-video/CRC.cpp index 42b87896d..491ae3d23 100644 --- a/Source/Project64-video/CRC.cpp +++ b/Source/Project64-video/CRC.cpp @@ -1,48 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// CRC32 calculation functions -// -// Created by Gonetz, 2004 -// -//**************************************************************** -//* +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #define CRC32_POLYNOMIAL 0x04C11DB7 unsigned int CRCTable[256]; diff --git a/Source/Project64-video/CRC.h b/Source/Project64-video/CRC.h index eb277dab3..2f51b15bd 100644 --- a/Source/Project64-video/CRC.h +++ b/Source/Project64-video/CRC.h @@ -1,47 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// CRC32 calculation functions -// -// Created by Gonetz, 2004 -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ void CRC_BuildTable(); diff --git a/Source/Project64-video/Combine.cpp b/Source/Project64-video/Combine.cpp index 3476b980e..fb640fe5a 100644 --- a/Source/Project64-video/Combine.cpp +++ b/Source/Project64-video/Combine.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include "Gfx_1.3.h" #include "Util.h" diff --git a/Source/Project64-video/Combine.h b/Source/Project64-video/Combine.h index cbd1b0ae9..5fb658353 100644 --- a/Source/Project64-video/Combine.h +++ b/Source/Project64-video/Combine.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef COMBINE_H #define COMBINE_H diff --git a/Source/Project64-video/Config.cpp b/Source/Project64-video/Config.cpp index d88406423..140522909 100644 --- a/Source/Project64-video/Config.cpp +++ b/Source/Project64-video/Config.cpp @@ -1,49 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64) -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Glide64 dialogs -// Created by Gonetz, 2008 -// -//**************************************************************** - -// -*- C++ -*- generated by wxGlade 0.6.3 on Tue Oct 07 22:39:28 2008 - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "Gfx_1.3.h" #include "DepthBufferRender.h" #include "Config.h" diff --git a/Source/Project64-video/Config.h b/Source/Project64-video/Config.h index a0685cc44..12eb8878c 100644 --- a/Source/Project64-video/Config.h +++ b/Source/Project64-video/Config.h @@ -1,46 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators (tested mostly with Project64) -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Glide64 dialogs -// Created by Gonetz, 2008 -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #pragma once #ifdef _WIN32 diff --git a/Source/Project64-video/Debugger.cpp b/Source/Project64-video/Debugger.cpp index 354630451..895a7bcbb 100644 --- a/Source/Project64-video/Debugger.cpp +++ b/Source/Project64-video/Debugger.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include diff --git a/Source/Project64-video/Debugger.h b/Source/Project64-video/Debugger.h index b19906bbf..e2f1e69f4 100644 --- a/Source/Project64-video/Debugger.h +++ b/Source/Project64-video/Debugger.h @@ -1,40 +1,14 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -void output (float x, float y, int scale, const char *fmt, ...); +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +void output(float x, float y, int scale, const char *fmt, ...); diff --git a/Source/Project64-video/DepthBufferRender.cpp b/Source/Project64-video/DepthBufferRender.cpp index 6297dc02c..8f455c6a0 100644 --- a/Source/Project64-video/DepthBufferRender.cpp +++ b/Source/Project64-video/DepthBufferRender.cpp @@ -1,50 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Software rendering into N64 depth buffer -// Idea and N64 depth value format by Orkin -// Polygon rasterization algorithm is taken from FATMAP2 engine by Mats Byggmastar, mri@penti.sit.fi -// -// Created by Gonetz, Dec 2004 -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "Gfx_1.3.h" #include "rdp.h" #include "DepthBufferRender.h" @@ -53,33 +19,33 @@ uint16_t * zLUT = 0; void ZLUT_init() { - if (zLUT) - return; - zLUT = new uint16_t[0x40000]; - for(int i=0; i<0x40000; i++) - { - uint32_t exponent = 0; - uint32_t testbit = 1 << 17; - while((i & testbit) && (exponent < 7)) + if (zLUT) + return; + zLUT = new uint16_t[0x40000]; + for (int i = 0; i < 0x40000; i++) { - exponent++; - testbit = 1 << (17 - exponent); + uint32_t exponent = 0; + uint32_t testbit = 1 << 17; + while ((i & testbit) && (exponent < 7)) + { + exponent++; + testbit = 1 << (17 - exponent); + } + + uint32_t mantissa = (i >> (6 - (6 < exponent ? 6 : exponent))) & 0x7ff; + zLUT[i] = (uint16_t)(((exponent << 11) | mantissa) << 2); } - - uint32_t mantissa = (i >> (6 - (6 < exponent ? 6 : exponent))) & 0x7ff; - zLUT[i] = (uint16_t)(((exponent << 11) | mantissa) << 2); - } } void ZLUT_release() { - delete[] zLUT; - zLUT = 0; + delete[] zLUT; + zLUT = 0; } static vertexi * max_vtx; // Max y vertex (ending vertex) -static vertexi * start_vtx, * end_vtx; // First and last vertex in array -static vertexi * right_vtx, * left_vtx; // Current right and left vertex +static vertexi * start_vtx, *end_vtx; // First and last vertex in array +static vertexi * right_vtx, *left_vtx; // Current right and left vertex static int right_height, left_height; static int right_x, right_dxdy, left_x, left_dxdy; @@ -103,210 +69,208 @@ __inline int idiv16(int x, int y) // (x << 16) / y __inline int iceil(int x) { - x += 0xffff; - return (x >> 16); + x += 0xffff; + return (x >> 16); } static void RightSection(void) { - // Walk backwards trough the vertex array - - vertexi * v2, * v1 = right_vtx; - if(right_vtx > start_vtx) v2 = right_vtx-1; - else v2 = end_vtx; // Wrap to end of array - right_vtx = v2; - - // v1 = top vertex - // v2 = bottom vertex - - // Calculate number of scanlines in this section - - right_height = iceil(v2->y) - iceil(v1->y); - if(right_height <= 0) return; - - // Guard against possible div overflows - - if(right_height > 1) { - // OK, no worries, we have a section that is at least - // one pixel high. Calculate slope as usual. - - int height = v2->y - v1->y; - right_dxdy = idiv16(v2->x - v1->x, height); - } - else { - // Height is less or equal to one pixel. - // Calculate slope = width * 1/height - // using 18:14 bit precision to avoid overflows. - - int inv_height = (0x10000 << 14) / (v2->y - v1->y); - right_dxdy = imul14(v2->x - v1->x, inv_height); - } - - // Prestep initial values - - int prestep = (iceil(v1->y) << 16) - v1->y; - right_x = v1->x + imul16(prestep, right_dxdy); + // Walk backwards trough the vertex array + + vertexi * v2, *v1 = right_vtx; + if (right_vtx > start_vtx) v2 = right_vtx - 1; + else v2 = end_vtx; // Wrap to end of array + right_vtx = v2; + + // v1 = top vertex + // v2 = bottom vertex + + // Calculate number of scanlines in this section + + right_height = iceil(v2->y) - iceil(v1->y); + if (right_height <= 0) return; + + // Guard against possible div overflows + + if (right_height > 1) { + // OK, no worries, we have a section that is at least + // one pixel high. Calculate slope as usual. + + int height = v2->y - v1->y; + right_dxdy = idiv16(v2->x - v1->x, height); + } + else { + // Height is less or equal to one pixel. + // Calculate slope = width * 1/height + // using 18:14 bit precision to avoid overflows. + + int inv_height = (0x10000 << 14) / (v2->y - v1->y); + right_dxdy = imul14(v2->x - v1->x, inv_height); + } + + // Prestep initial values + + int prestep = (iceil(v1->y) << 16) - v1->y; + right_x = v1->x + imul16(prestep, right_dxdy); } static void LeftSection(void) { - // Walk forward trough the vertex array - - vertexi * v2, * v1 = left_vtx; - if(left_vtx < end_vtx) v2 = left_vtx+1; - else v2 = start_vtx; // Wrap to start of array - left_vtx = v2; - - // v1 = top vertex - // v2 = bottom vertex - - // Calculate number of scanlines in this section - - left_height = iceil(v2->y) - iceil(v1->y); - if(left_height <= 0) return; - - // Guard against possible div overflows - - if(left_height > 1) { - // OK, no worries, we have a section that is at least - // one pixel high. Calculate slope as usual. - - int height = v2->y - v1->y; - left_dxdy = idiv16(v2->x - v1->x, height); - left_dzdy = idiv16(v2->z - v1->z, height); - } - else { - // Height is less or equal to one pixel. - // Calculate slope = width * 1/height - // using 18:14 bit precision to avoid overflows. - - int inv_height = (0x10000 << 14) / (v2->y - v1->y); - left_dxdy = imul14(v2->x - v1->x, inv_height); - left_dzdy = imul14(v2->z - v1->z, inv_height); - } - - // Prestep initial values - - int prestep = (iceil(v1->y) << 16) - v1->y; - left_x = v1->x + imul16(prestep, left_dxdy); - left_z = v1->z + imul16(prestep, left_dzdy); -} + // Walk forward trough the vertex array + vertexi * v2, *v1 = left_vtx; + if (left_vtx < end_vtx) v2 = left_vtx + 1; + else v2 = start_vtx; // Wrap to start of array + left_vtx = v2; + + // v1 = top vertex + // v2 = bottom vertex + + // Calculate number of scanlines in this section + + left_height = iceil(v2->y) - iceil(v1->y); + if (left_height <= 0) return; + + // Guard against possible div overflows + + if (left_height > 1) { + // OK, no worries, we have a section that is at least + // one pixel high. Calculate slope as usual. + + int height = v2->y - v1->y; + left_dxdy = idiv16(v2->x - v1->x, height); + left_dzdy = idiv16(v2->z - v1->z, height); + } + else { + // Height is less or equal to one pixel. + // Calculate slope = width * 1/height + // using 18:14 bit precision to avoid overflows. + + int inv_height = (0x10000 << 14) / (v2->y - v1->y); + left_dxdy = imul14(v2->x - v1->x, inv_height); + left_dzdy = imul14(v2->z - v1->z, inv_height); + } + + // Prestep initial values + + int prestep = (iceil(v1->y) << 16) - v1->y; + left_x = v1->x + imul16(prestep, left_dxdy); + left_z = v1->z + imul16(prestep, left_dzdy); +} void Rasterize(vertexi * vtx, int vertices, int dzdx) { - start_vtx = vtx; // First vertex in array - - // Search trough the vtx array to find min y, max y - // and the location of these structures. - - vertexi * min_vtx = vtx; - max_vtx = vtx; - - int min_y = vtx->y; - int max_y = vtx->y; - - vtx++; - - for(int n=1; ny < min_y) { - min_y = vtx->y; - min_vtx = vtx; + start_vtx = vtx; // First vertex in array + + // Search trough the vtx array to find min y, max y + // and the location of these structures. + + vertexi * min_vtx = vtx; + max_vtx = vtx; + + int min_y = vtx->y; + int max_y = vtx->y; + + vtx++; + + for (int n = 1; n < vertices; n++) { + if (vtx->y < min_y) { + min_y = vtx->y; + min_vtx = vtx; + } + else + if (vtx->y > max_y) { + max_y = vtx->y; + max_vtx = vtx; + } + vtx++; } - else - if(vtx->y > max_y) { - max_y = vtx->y; - max_vtx = vtx; - } - vtx++; - } - - // OK, now we know where in the array we should start and - // where to end while scanning the edges of the polygon - - left_vtx = min_vtx; // Left side starting vertex - right_vtx = min_vtx; // Right side starting vertex - end_vtx = vtx-1; // Last vertex in array - - // Search for the first usable right section - - do { - if(right_vtx == max_vtx) return; - RightSection(); - } while(right_height <= 0); - - // Search for the first usable left section - - do { - if(left_vtx == max_vtx) return; - LeftSection(); - } while(left_height <= 0); - - uint16_t * destptr = (uint16_t*)(gfx.RDRAM+rdp.zimg); - int y1 = iceil(min_y); - if (y1 >= (int)rdp.scissor_o.lr_y) return; - int shift; - - for(;;) - { - int x1 = iceil(left_x); - if (x1 < (int)rdp.scissor_o.ul_x) - x1 = rdp.scissor_o.ul_x; - int width = iceil(right_x) - x1; - if (x1+width >= (int)rdp.scissor_o.lr_x) - width = rdp.scissor_o.lr_x - x1 - 1; - - if(width > 0 && y1 >= (int)rdp.scissor_o.ul_y) { - - // Prestep initial z - - int prestep = (x1 << 16) - left_x; - int z = left_z + imul16(prestep, dzdx); - - shift = x1 + y1*rdp.zi_width; - //draw to depth buffer - int trueZ; - int idx; - uint16_t encodedZ; - for (int x = 0; x < width; x++) - { - trueZ = z/8192; - if (trueZ < 0) trueZ = 0; - else if (trueZ > 0x3FFFF) trueZ = 0x3FFFF; - encodedZ = zLUT[trueZ]; - idx = (shift+x)^1; - if(encodedZ < destptr[idx]) - destptr[idx] = encodedZ; - z += dzdx; - } - } - - //destptr += rdp.zi_width; - y1++; - if (y1 >= (int)rdp.scissor_o.lr_y) return; - - // Scan the right side - - if(--right_height <= 0) { // End of this section? - do { - if(right_vtx == max_vtx) return; + + // OK, now we know where in the array we should start and + // where to end while scanning the edges of the polygon + + left_vtx = min_vtx; // Left side starting vertex + right_vtx = min_vtx; // Right side starting vertex + end_vtx = vtx - 1; // Last vertex in array + + // Search for the first usable right section + + do { + if (right_vtx == max_vtx) return; RightSection(); - } while(right_height <= 0); - } - else - right_x += right_dxdy; - - // Scan the left side - - if(--left_height <= 0) { // End of this section? - do { - if(left_vtx == max_vtx) return; + } while (right_height <= 0); + + // Search for the first usable left section + + do { + if (left_vtx == max_vtx) return; LeftSection(); - } while(left_height <= 0); + } while (left_height <= 0); + + uint16_t * destptr = (uint16_t*)(gfx.RDRAM + rdp.zimg); + int y1 = iceil(min_y); + if (y1 >= (int)rdp.scissor_o.lr_y) return; + int shift; + + for (;;) + { + int x1 = iceil(left_x); + if (x1 < (int)rdp.scissor_o.ul_x) + x1 = rdp.scissor_o.ul_x; + int width = iceil(right_x) - x1; + if (x1 + width >= (int)rdp.scissor_o.lr_x) + width = rdp.scissor_o.lr_x - x1 - 1; + + if (width > 0 && y1 >= (int)rdp.scissor_o.ul_y) { + // Prestep initial z + + int prestep = (x1 << 16) - left_x; + int z = left_z + imul16(prestep, dzdx); + + shift = x1 + y1*rdp.zi_width; + //draw to depth buffer + int trueZ; + int idx; + uint16_t encodedZ; + for (int x = 0; x < width; x++) + { + trueZ = z / 8192; + if (trueZ < 0) trueZ = 0; + else if (trueZ > 0x3FFFF) trueZ = 0x3FFFF; + encodedZ = zLUT[trueZ]; + idx = (shift + x) ^ 1; + if (encodedZ < destptr[idx]) + destptr[idx] = encodedZ; + z += dzdx; + } + } + + //destptr += rdp.zi_width; + y1++; + if (y1 >= (int)rdp.scissor_o.lr_y) return; + + // Scan the right side + + if (--right_height <= 0) { // End of this section? + do { + if (right_vtx == max_vtx) return; + RightSection(); + } while (right_height <= 0); + } + else + right_x += right_dxdy; + + // Scan the left side + + if (--left_height <= 0) { // End of this section? + do { + if (left_vtx == max_vtx) return; + LeftSection(); + } while (left_height <= 0); + } + else { + left_x += left_dxdy; + left_z += left_dzdy; + } } - else { - left_x += left_dxdy; - left_z += left_dzdy; - } - } } diff --git a/Source/Project64-video/DepthBufferRender.h b/Source/Project64-video/DepthBufferRender.h index 122655234..ae15e95d4 100644 --- a/Source/Project64-video/DepthBufferRender.h +++ b/Source/Project64-video/DepthBufferRender.h @@ -1,53 +1,22 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Software rendering to N64 depth buffer -// Created by Gonetz, Dec 2004 -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef DEPTH_BUFFER_RENDER_H #define DEPTH_BUFFER_RENDER_H struct vertexi { - int x,y; // Screen position in 16:16 bit fixed point + int x, y; // Screen position in 16:16 bit fixed point int z; // z value in 16:16 bit fixed point }; diff --git a/Source/Project64-video/Ext_TxFilter.cpp b/Source/Project64-video/Ext_TxFilter.cpp index a9c167211..6763ed727 100644 --- a/Source/Project64-video/Ext_TxFilter.cpp +++ b/Source/Project64-video/Ext_TxFilter.cpp @@ -1,26 +1,15 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include #include "Ext_TxFilter.h" diff --git a/Source/Project64-video/Ext_TxFilter.h b/Source/Project64-video/Ext_TxFilter.h index 34a411485..7b93030ce 100644 --- a/Source/Project64-video/Ext_TxFilter.h +++ b/Source/Project64-video/Ext_TxFilter.h @@ -1,25 +1,15 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __EXT_TXFILTER_H__ #define __EXT_TXFILTER_H__ diff --git a/Source/Project64-video/FBtoScreen.cpp b/Source/Project64-video/FBtoScreen.cpp index 722828378..5f8130bcf 100644 --- a/Source/Project64-video/FBtoScreen.cpp +++ b/Source/Project64-video/FBtoScreen.cpp @@ -1,47 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Draw N64 frame buffer to screen. -// Created by Gonetz, 2007 -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "Gfx_1.3.h" #include "FBtoScreen.h" #include "TexCache.h" diff --git a/Source/Project64-video/FBtoScreen.h b/Source/Project64-video/FBtoScreen.h index 2fe1b6dbc..7602275f0 100644 --- a/Source/Project64-video/FBtoScreen.h +++ b/Source/Project64-video/FBtoScreen.h @@ -1,60 +1,30 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Render N64 frame buffer to screen -// Created by Gonetz, 2007 -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef FBtoSCREEN_H #define FBtoSCREEN_H -typedef struct +typedef struct { - uint32_t addr; //color image address - uint32_t size; - uint32_t width; - uint32_t height; - uint32_t ul_x; - uint32_t ul_y; - uint32_t lr_x; - uint32_t lr_y; - uint32_t opaque; + uint32_t addr; //color image address + uint32_t size; + uint32_t width; + uint32_t height; + uint32_t ul_x; + uint32_t ul_y; + uint32_t lr_x; + uint32_t lr_y; + uint32_t opaque; } FB_TO_SCREEN_INFO; bool DrawFrameBufferToScreen(FB_TO_SCREEN_INFO & fb_info); diff --git a/Source/Project64-video/Gfx_1.3.h b/Source/Project64-video/Gfx_1.3.h index b3beb5db8..6ae87d026 100644 --- a/Source/Project64-video/Gfx_1.3.h +++ b/Source/Project64-video/Gfx_1.3.h @@ -1,67 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -/********************************************************************************** -Common gfx plugin spec, version #1.3 maintained by zilmar (zilmar@emulation64.com) - -All questions or suggestions should go through the mailing list. -http://www.egroups.com/group/Plugin64-Dev -*********************************************************************************** - -Notes: ------- - -Setting the approprate bits in the MI_INTR_REG and calling CheckInterrupts which -are both passed to the DLL in InitiateGFX will generate an Interrupt from with in -the plugin. - -The Setting of the RSP flags and generating an SP interrupt should not be done in -the plugin - -**********************************************************************************/ - -// THIS FILE IS A PRECOMPILED HEADER TO DECREASE BUILD TIME. INCLUDE ALL STANDARD -// .H FILES HERE - -#ifndef _GFX_H_INCLUDED__ -#define _GFX_H_INCLUDED__ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once #include "winlnxdefs.h" #include @@ -533,4 +483,3 @@ extern "C" { #if defined(__cplusplus) } #endif -#endif //_GFX_H_INCLUDED__ diff --git a/Source/Project64-video/Main.cpp b/Source/Project64-video/Main.cpp index 7898354d1..f249b0400 100644 --- a/Source/Project64-video/Main.cpp +++ b/Source/Project64-video/Main.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include #include "Gfx_1.3.h" diff --git a/Source/Project64-video/MiClWr16b.h b/Source/Project64-video/MiClWr16b.h index e34c893ff..36b4e6434 100644 --- a/Source/Project64-video/MiClWr16b.h +++ b/Source/Project64-video/MiClWr16b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include typedef uint32_t uint32_t; diff --git a/Source/Project64-video/MiClWr32b.h b/Source/Project64-video/MiClWr32b.h index 94224e714..095cdbd03 100644 --- a/Source/Project64-video/MiClWr32b.h +++ b/Source/Project64-video/MiClWr32b.h @@ -1,46 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Created by Gonetz, 2007 -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include static inline void mirror32bS(uint8_t *tex, uint8_t *start, int width, int height, int mask, int line, int full, int count) diff --git a/Source/Project64-video/MiClWr8b.h b/Source/Project64-video/MiClWr8b.h index 7d322f93d..8b59cf54c 100644 --- a/Source/Project64-video/MiClWr8b.h +++ b/Source/Project64-video/MiClWr8b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ //**************************************************************** // 8-bit Horizontal Mirror diff --git a/Source/Project64-video/Renderer/OGLEScombiner.cpp b/Source/Project64-video/Renderer/OGLEScombiner.cpp index a348d68cd..0d57fc0e4 100644 --- a/Source/Project64-video/Renderer/OGLEScombiner.cpp +++ b/Source/Project64-video/Renderer/OGLEScombiner.cpp @@ -1,23 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #include #else // _WIN32 diff --git a/Source/Project64-video/Renderer/OGLESgeometry.cpp b/Source/Project64-video/Renderer/OGLESgeometry.cpp index 10cd0f883..079c4a311 100644 --- a/Source/Project64-video/Renderer/OGLESgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLESgeometry.cpp @@ -1,22 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include diff --git a/Source/Project64-video/Renderer/OGLESglitchmain.cpp b/Source/Project64-video/Renderer/OGLESglitchmain.cpp index 8e6f8daed..002021357 100644 --- a/Source/Project64-video/Renderer/OGLESglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLESglitchmain.cpp @@ -1,22 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #define SAVE_CBUFFER diff --git a/Source/Project64-video/Renderer/OGLEStextures.cpp b/Source/Project64-video/Renderer/OGLEStextures.cpp index c3e869696..37bdb3f51 100644 --- a/Source/Project64-video/Renderer/OGLEStextures.cpp +++ b/Source/Project64-video/Renderer/OGLEStextures.cpp @@ -1,23 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #include #else // _WIN32 diff --git a/Source/Project64-video/Renderer/OGLESwrappers.cpp b/Source/Project64-video/Renderer/OGLESwrappers.cpp index cd271bd19..0bbadf878 100644 --- a/Source/Project64-video/Renderer/OGLESwrappers.cpp +++ b/Source/Project64-video/Renderer/OGLESwrappers.cpp @@ -1,22 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include "glitchmain.h" diff --git a/Source/Project64-video/Renderer/OGLESwrappers.h b/Source/Project64-video/Renderer/OGLESwrappers.h index 75b6ff6e8..feccc908d 100644 --- a/Source/Project64-video/Renderer/OGLESwrappers.h +++ b/Source/Project64-video/Renderer/OGLESwrappers.h @@ -1,3 +1,16 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #pragma once #include #include diff --git a/Source/Project64-video/Renderer/OGLcombiner.cpp b/Source/Project64-video/Renderer/OGLcombiner.cpp index cf44637a0..d66120e8d 100644 --- a/Source/Project64-video/Renderer/OGLcombiner.cpp +++ b/Source/Project64-video/Renderer/OGLcombiner.cpp @@ -1,3 +1,16 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #include #else // _WIN32 diff --git a/Source/Project64-video/Renderer/OGLgeometry.cpp b/Source/Project64-video/Renderer/OGLgeometry.cpp index cbb33163d..bd7d0fe8c 100644 --- a/Source/Project64-video/Renderer/OGLgeometry.cpp +++ b/Source/Project64-video/Renderer/OGLgeometry.cpp @@ -1,3 +1,16 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #ifdef _WIN32 #include diff --git a/Source/Project64-video/Renderer/OGLglitchmain.cpp b/Source/Project64-video/Renderer/OGLglitchmain.cpp index 3c6e7720c..db17251ba 100644 --- a/Source/Project64-video/Renderer/OGLglitchmain.cpp +++ b/Source/Project64-video/Renderer/OGLglitchmain.cpp @@ -1,3 +1,16 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #define SAVE_CBUFFER #ifdef _WIN32 diff --git a/Source/Project64-video/Renderer/OGLtextures.cpp b/Source/Project64-video/Renderer/OGLtextures.cpp index 2c8331d2a..bd7be6df1 100644 --- a/Source/Project64-video/Renderer/OGLtextures.cpp +++ b/Source/Project64-video/Renderer/OGLtextures.cpp @@ -1,3 +1,16 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #include #else // _WIN32 diff --git a/Source/Project64-video/Renderer/glitchmain.h b/Source/Project64-video/Renderer/glitchmain.h index 4f998502a..8cbcc984b 100644 --- a/Source/Project64-video/Renderer/glitchmain.h +++ b/Source/Project64-video/Renderer/glitchmain.h @@ -1,5 +1,17 @@ -#ifndef MAIN_H -#define MAIN_H +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once #ifndef _WIN32 //#define VPDEBUG @@ -260,4 +272,3 @@ FX_ENTRY void FX_CALL void CHECK_FRAMEBUFFER_STATUS(void); -#endif diff --git a/Source/Project64-video/ScreenResolution.cpp b/Source/Project64-video/ScreenResolution.cpp index 962819ec5..d54fedc74 100644 --- a/Source/Project64-video/ScreenResolution.cpp +++ b/Source/Project64-video/ScreenResolution.cpp @@ -1,8 +1,8 @@ /**************************************************************************** * * -* Project64 - A Nintendo 64 emulator. * +* Project64-video - A Nintendo 64 gfx plugin. * * http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * +* Copyright (C) 2017 Project64. All rights reserved. * * * * License: * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * diff --git a/Source/Project64-video/ScreenResolution.h b/Source/Project64-video/ScreenResolution.h index 81d0cab67..80a8f2b84 100644 --- a/Source/Project64-video/ScreenResolution.h +++ b/Source/Project64-video/ScreenResolution.h @@ -1,8 +1,8 @@ /**************************************************************************** * * -* Project64 - A Nintendo 64 emulator. * +* Project64-video - A Nintendo 64 gfx plugin. * * http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * +* Copyright (C) 2017 Project64. All rights reserved. * * * * License: * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * diff --git a/Source/Project64-video/Settings.cpp b/Source/Project64-video/Settings.cpp index 91bec7fab..0fa54cb32 100644 --- a/Source/Project64-video/Settings.cpp +++ b/Source/Project64-video/Settings.cpp @@ -1,3 +1,13 @@ +/**************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ #include #include #include diff --git a/Source/Project64-video/Settings.h b/Source/Project64-video/Settings.h index ada31c806..bf28312f4 100644 --- a/Source/Project64-video/Settings.h +++ b/Source/Project64-video/Settings.h @@ -1,10 +1,20 @@ +/**************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ #pragma once #include class CSettings { public: - CSettings(); + CSettings(); //Frame buffer emulation options enum fb_bits_t @@ -27,37 +37,37 @@ public: enum hacks_t { - hack_ASB = (1<<0), //All-Star Baseball games - hack_Banjo2 = (1<<1), //Banjo Tooie - hack_BAR = (1<<2), //Beetle Adventure Racing - hack_Chopper = (1<<3), //Chopper Attack - hack_Diddy = (1<<4), //diddy kong racing - hack_Fifa98 = (1<<5), //FIFA - Road to World Cup 98 - hack_Fzero = (1<<6), //F-Zero - hack_GoldenEye = (1<<7), //Golden Eye - hack_Hyperbike = (1<<8), //Top Gear Hyper Bike - hack_ISS64 = (1<<9), //International Superstar Soccer 64 - hack_KI = (1<<10), //Killer Instinct - hack_Knockout = (1<<11), //Knockout Kings 2000 - hack_Lego = (1<<12), //LEGO Racers - hack_MK64 = (1<<13), //Mario Kart - hack_Megaman = (1<<14), //Megaman64 - hack_Makers = (1<<15), //Mischief-makers - hack_WCWnitro = (1<<16), //WCW Nitro - hack_Ogre64 = (1<<17), //Ogre Battle 64 - hack_Pilotwings = (1<<18), //Pilotwings - hack_PMario = (1<<19), //Paper Mario - hack_PPL = (1<<20), //pokemon puzzle league requires many special fixes - hack_RE2 = (1<<21), //Resident Evil 2 - hack_Starcraft = (1<<22), //StarCraft64 - hack_Supercross = (1<<23), //Supercross 2000 - hack_TGR = (1<<24), //Top Gear Rally - hack_TGR2 = (1<<25), //Top Gear Rally 2 - hack_Tonic = (1<<26), //tonic trouble - hack_Winback = (1<<27), //WinBack - Covert Operations - hack_Yoshi = (1<<28), //Yoshi Story - hack_Zelda = (1<<29), //zeldas hacks - hack_OoT = (1<<30), //zelda OoT hacks + hack_ASB = (1 << 0), //All-Star Baseball games + hack_Banjo2 = (1 << 1), //Banjo Tooie + hack_BAR = (1 << 2), //Beetle Adventure Racing + hack_Chopper = (1 << 3), //Chopper Attack + hack_Diddy = (1 << 4), //diddy kong racing + hack_Fifa98 = (1 << 5), //FIFA - Road to World Cup 98 + hack_Fzero = (1 << 6), //F-Zero + hack_GoldenEye = (1 << 7), //Golden Eye + hack_Hyperbike = (1 << 8), //Top Gear Hyper Bike + hack_ISS64 = (1 << 9), //International Superstar Soccer 64 + hack_KI = (1 << 10), //Killer Instinct + hack_Knockout = (1 << 11), //Knockout Kings 2000 + hack_Lego = (1 << 12), //LEGO Racers + hack_MK64 = (1 << 13), //Mario Kart + hack_Megaman = (1 << 14), //Megaman64 + hack_Makers = (1 << 15), //Mischief-makers + hack_WCWnitro = (1 << 16), //WCW Nitro + hack_Ogre64 = (1 << 17), //Ogre Battle 64 + hack_Pilotwings = (1 << 18), //Pilotwings + hack_PMario = (1 << 19), //Paper Mario + hack_PPL = (1 << 20), //pokemon puzzle league requires many special fixes + hack_RE2 = (1 << 21), //Resident Evil 2 + hack_Starcraft = (1 << 22), //StarCraft64 + hack_Supercross = (1 << 23), //Supercross 2000 + hack_TGR = (1 << 24), //Top Gear Rally + hack_TGR2 = (1 << 25), //Top Gear Rally 2 + hack_Tonic = (1 << 26), //tonic trouble + hack_Winback = (1 << 27), //WinBack - Covert Operations + hack_Yoshi = (1 << 28), //Yoshi Story + hack_Zelda = (1 << 29), //zeldas hacks + hack_OoT = (1 << 30), //zelda OoT hacks }; enum AspectMode_t @@ -117,7 +127,7 @@ public: HiResPackFormat_None = 0, HiResPackFormat_Riceformat = 0x00020000, }; - + enum SwapMode_t { SwapMode_Old = 0, @@ -172,7 +182,7 @@ public: inline bool fb_emulation_enabled(void) const { return ((m_frame_buffer&fb_emulation) != 0); } inline bool fb_ref_enabled(void) const { return ((m_frame_buffer&fb_ref) != 0); } - inline bool fb_hwfbe_enabled(void) const { return ((m_frame_buffer&(fb_emulation |fb_hwfbe)) == (fb_emulation | fb_hwfbe)); } + inline bool fb_hwfbe_enabled(void) const { return ((m_frame_buffer&(fb_emulation | fb_hwfbe)) == (fb_emulation | fb_hwfbe)); } inline bool fb_hwfbe_set(void) const { return ((m_frame_buffer&fb_hwfbe) != 0); } inline bool fb_depth_render_enabled(void) const { return ((m_frame_buffer&fb_depth_render) != 0); } inline bool fb_get_info_enabled(void) const { return ((m_frame_buffer&fb_get_info) != 0); } @@ -199,7 +209,7 @@ public: inline ScreenRotate_t rotate(void) const { return m_rotate; } inline Filtering_t filtering(void) const { return m_filtering; } - inline bool fog (void) const { return m_fog; } + inline bool fog(void) const { return m_fog; } inline bool buff_clear(void) const { return m_buff_clear; } inline SwapMode_t swapmode(void) const { return m_swapmode; } inline PixelLevelOfDetail_t lodmode(void) const { return m_lodmode; } @@ -255,9 +265,9 @@ public: inline bool zmode_compare_less(void) const { return m_zmode_compare_less; } //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating) inline bool old_style_adither(void) const { return m_old_style_adither; } //apply alpha dither regardless of alpha_dither_mode inline bool n64_z_scale(void) const { return m_n64_z_scale; } //scale vertex z value before writing to depth buffer, as N64 does. - + inline bool hacks(hacks_t hack) const { return (m_hacks & hack) == hack; } //Special game hacks - + //wrapper settings #ifndef ANDROID inline uint32_t FullScreenRes(void) const { return m_FullScreenRes; } @@ -288,7 +298,7 @@ public: void SetGhqHirsF16bpp(bool value); void SetGhqHirsDump(bool value); void SetGhqEnhtNobg(bool value); - void SetGhqEnhtCmpr(bool value); + void SetGhqEnhtCmpr(bool value); void SetGhqHirsAltcrc(bool value); void SetGhqHirsCmpr(bool value); void SetGhqHirsGz(bool value); diff --git a/Source/Project64-video/SettingsID.h b/Source/Project64-video/SettingsID.h index b75fd9757..aeaa9d16d 100644 --- a/Source/Project64-video/SettingsID.h +++ b/Source/Project64-video/SettingsID.h @@ -1,8 +1,8 @@ /**************************************************************************** * * -* Project 64 - A Nintendo 64 emulator. * +* Project64-video - A Nintendo 64 gfx plugin. * * http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * +* Copyright (C) 2017 Project64. All rights reserved. * * * * License: * * GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * diff --git a/Source/Project64-video/TexBuffer.cpp b/Source/Project64-video/TexBuffer.cpp index 9ac5539ff..6f7cf15ea 100644 --- a/Source/Project64-video/TexBuffer.cpp +++ b/Source/Project64-video/TexBuffer.cpp @@ -1,47 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Hardware frame buffer emulation -// Dec 2003 created by Gonetz -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include "Gfx_1.3.h" #include "TexBuffer.h" diff --git a/Source/Project64-video/TexBuffer.h b/Source/Project64-video/TexBuffer.h index 931019504..677c24a68 100644 --- a/Source/Project64-video/TexBuffer.h +++ b/Source/Project64-video/TexBuffer.h @@ -1,47 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Hardware frame buffer emulation -// Dec 2003 created by Gonetz -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef TEXBUFFER_H #define TEXBUFFER_H diff --git a/Source/Project64-video/TexCache.cpp b/Source/Project64-video/TexCache.cpp index bbc2711ed..bc49d7a0f 100644 --- a/Source/Project64-video/TexCache.cpp +++ b/Source/Project64-video/TexCache.cpp @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "Gfx_1.3.h" #include "TexCache.h" diff --git a/Source/Project64-video/TexCache.h b/Source/Project64-video/TexCache.h index d2e3d8041..366b2e558 100644 --- a/Source/Project64-video/TexCache.h +++ b/Source/Project64-video/TexCache.h @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef TEXCACHE_H #define TEXCACHE_H diff --git a/Source/Project64-video/TexConv.h b/Source/Project64-video/TexConv.h index 694a4f691..42de5d510 100644 --- a/Source/Project64-video/TexConv.h +++ b/Source/Project64-video/TexConv.h @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static inline void texConv_ARGB1555_ARGB4444(uint8_t *src, uint8_t *dst, int size) { uint32_t *v3; diff --git a/Source/Project64-video/TexLoad.h b/Source/Project64-video/TexLoad.h index 568b574e5..b54a9551c 100644 --- a/Source/Project64-video/TexLoad.h +++ b/Source/Project64-video/TexLoad.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "TexLoad4b.h" #include "TexLoad8b.h" diff --git a/Source/Project64-video/TexLoad16b.h b/Source/Project64-video/TexLoad16b.h index af751d50c..df5ef5379 100644 --- a/Source/Project64-video/TexLoad16b.h +++ b/Source/Project64-video/TexLoad16b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static inline void load16bRGBA(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext) { diff --git a/Source/Project64-video/TexLoad32b.h b/Source/Project64-video/TexLoad32b.h index 028527aa2..199c66ad4 100644 --- a/Source/Project64-video/TexLoad32b.h +++ b/Source/Project64-video/TexLoad32b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ //**************************************************************** // Size: 2, Format: 0 diff --git a/Source/Project64-video/TexLoad4b.h b/Source/Project64-video/TexLoad4b.h index 0aac3ea61..013d17c05 100644 --- a/Source/Project64-video/TexLoad4b.h +++ b/Source/Project64-video/TexLoad4b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static inline void load4bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, uint16_t line, int ext, uint16_t *pal) { diff --git a/Source/Project64-video/TexLoad8b.h b/Source/Project64-video/TexLoad8b.h index b482142a4..82e1e9cca 100644 --- a/Source/Project64-video/TexLoad8b.h +++ b/Source/Project64-video/TexLoad8b.h @@ -1,41 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static inline void load8bCI(uint8_t *src, uint8_t *dst, int wid_64, int height, int line, int ext, uint16_t *pal) { diff --git a/Source/Project64-video/TexMod.h b/Source/Project64-video/TexMod.h index b0ec9c0c2..c822a58dc 100644 --- a/Source/Project64-video/TexMod.h +++ b/Source/Project64-video/TexMod.h @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static void mod_tex_inter_color_using_factor(uint16_t *dst, int size, uint32_t color, uint32_t factor) { float percent = factor / 255.0f; diff --git a/Source/Project64-video/TexModCI.h b/Source/Project64-video/TexModCI.h index 2ec35307f..96980e4de 100644 --- a/Source/Project64-video/TexModCI.h +++ b/Source/Project64-video/TexModCI.h @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ static void mod_tex_inter_color_using_factor_CI(uint32_t color, uint32_t factor) { float percent = factor / 255.0f; @@ -171,7 +145,7 @@ static void mod_tex_sub_col_mul_fac_add_tex_CI(uint32_t color, uint32_t factor) cg = (uint8_t)((color >> 16) & 0xFF); cb = (uint8_t)((color >> 8) & 0xFF); - for (int i = 0; i<256; i++) + for (int i = 0; i < 256; i++) { col = rdp.pal_8[i]; a = (uint8_t)(col & 0x0001);; @@ -290,7 +264,7 @@ static void mod_tex_sub_col_mul_fac_CI(uint32_t color, uint32_t factor) cg = (uint8_t)((color >> 16) & 0xFF); cb = (uint8_t)((color >> 8) & 0xFF); - for (int i = 0; i<256; i++) + for (int i = 0; i < 256; i++) { col = rdp.pal_8[i]; a = (uint8_t)(col & 0x0001); diff --git a/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h b/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h index b9d7a83a4..32cd18b7a 100644 --- a/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h +++ b/Source/Project64-video/TextureEnhancer/Ext_TxFilter.h @@ -1,58 +1,18 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __EXT_TXFILTER_H__ -#define __EXT_TXFILTER_H__ - -#ifdef _WIN32 -#include -#define TXHMODULE HMODULE -#define DLOPEN(a) LoadLibraryW(a) -#define DLCLOSE(a) FreeLibrary(a) -#define DLSYM(a, b) GetProcAddress(a, b) -#define GETCWD(a, b) GetCurrentDirectoryW(a, b) -#define CHDIR(a) SetCurrentDirectoryW(a) -#else -#include -#include -#define MAX_PATH 4095 -#define TXHMODULE void* -#define DLOPEN(a) dlopen(a, RTLD_LAZY|RTLD_GLOBAL) -#define DLCLOSE(a) dlclose(a) -#define DLSYM(a, b) dlsym(a, b) -#define GETCWD(a, b) getcwd(b, a) -#define CHDIR(a) chdir(a) -#endif - -#ifdef WIN32 -typedef __int64 int64; -typedef unsigned __int64 uint64; -typedef unsigned char boolean; -#else -typedef long long int64; -typedef unsigned long long uint64; -typedef unsigned char boolean; -#endif +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once +#include #define NO_OPTIONS 0x00000000 @@ -104,44 +64,21 @@ typedef unsigned char boolean; #define LET_TEXARTISTS_FLY 0x40000000 /* a little freedom for texture artists */ #define DUMP_TEX 0x80000000 -#ifndef __GLIDE_H__ /* GLIDE3 */ -/* from 3Dfx Interactive Inc. glide.h */ -#define GR_TEXFMT_ALPHA_8 0x2 -#define GR_TEXFMT_INTENSITY_8 0x3 - -#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4 -#define GR_TEXFMT_P_8 0x5 - -#define GR_TEXFMT_RGB_565 0xa -#define GR_TEXFMT_ARGB_1555 0xb -#define GR_TEXFMT_ARGB_4444 0xc -#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd - -/* from 3Dfx Interactive Inc. g3ext.h */ -#define GR_TEXFMT_ARGB_CMP_FXT1 0x11 - -#define GR_TEXFMT_ARGB_8888 0x12 - -#define GR_TEXFMT_ARGB_CMP_DXT1 0x16 -#define GR_TEXFMT_ARGB_CMP_DXT3 0x18 -#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A -#endif /* GLIDE3 */ - struct GHQTexInfo { - unsigned char *data; - int width; - int height; - unsigned short format; + unsigned char *data; + int width; + int height; + unsigned short format; - int smallLodLog2; - int largeLodLog2; - int aspectRatioLog2; + int smallLodLog2; + int largeLodLog2; + int aspectRatioLog2; - int tiles; - int untiled_width; - int untiled_height; + int tiles; + int untiled_width; + int untiled_height; - unsigned char is_hires_tex; + unsigned char is_hires_tex; }; /* Callback to display hires texture info. @@ -159,54 +96,53 @@ struct GHQTexInfo { * printf(buf); * } */ + #define INFO_BUF 4095 -typedef void (*dispInfoFuncExt)(const char *format, ...); +typedef void(*dispInfoFuncExt)(const char *format, ...); #ifndef TXFILTER_DLL -boolean ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */ - int maxheight,/* maximum texture height supported by hardware */ - int maxbpp, /* maximum texture bpp supported by hardware */ - int options, /* options */ - int cachesize,/* cache textures to system memory */ - const char *path, /* plugin directory. must be smaller than MAX_PATH */ - const char *ident, /* name of ROM. must be no longer than 64 in character. */ - dispInfoFuncExt callback /* callback function to display info */ - ); +bool ext_ghq_init(int maxwidth, /* maximum texture width supported by hardware */ + int maxheight,/* maximum texture height supported by hardware */ + int maxbpp, /* maximum texture bpp supported by hardware */ + int options, /* options */ + int cachesize,/* cache textures to system memory */ + const char *path, /* plugin directory. must be smaller than MAX_PATH */ + const char *ident, /* name of ROM. must be no longer than 64 in character. */ + dispInfoFuncExt callback /* callback function to display info */ +); void ext_ghq_shutdown(void); -boolean ext_ghq_txfilter(unsigned char *src, /* input texture */ - int srcwidth, /* width of input texture */ - int srcheight, /* height of input texture */ - unsigned short srcformat, /* format of input texture */ - uint64 g64crc, /* glide64 crc */ - GHQTexInfo *info /* output */ - ); +bool ext_ghq_txfilter(unsigned char *src, /* input texture */ + int srcwidth, /* width of input texture */ + int srcheight, /* height of input texture */ + unsigned short srcformat, /* format of input texture */ + uint64_t g64crc, /* glide64 crc */ + GHQTexInfo *info /* output */ +); -boolean ext_ghq_hirestex(uint64 g64crc, /* glide64 crc */ - uint64 r_crc64, /* checksum hi:palette low:texture */ - unsigned short *palette, /* palette for CI textures */ - GHQTexInfo *info /* output */ - ); +bool ext_ghq_hirestex(uint64_t g64crc, /* glide64 crc */ + uint64_t r_crc64, /* checksum hi:palette low:texture */ + unsigned short *palette, /* palette for CI textures */ + GHQTexInfo *info /* output */ +); -uint64 ext_ghq_checksum(unsigned char *src, /* input texture */ - int width, /* width of texture */ - int height, /* height of texture */ - int size, /* type of texture pixel */ - int rowStride, /* row stride in bytes */ - unsigned char *palette /* palette */ - ); +uint64_t ext_ghq_checksum(unsigned char *src, /* input texture */ + int width, /* width of texture */ + int height, /* height of texture */ + int size, /* type of texture pixel */ + int rowStride, /* row stride in bytes */ + unsigned char *palette /* palette */ +); -boolean ext_ghq_dmptx(unsigned char *src, /* input texture (must be in 3Dfx Glide format) */ - int width, /* width of texture */ - int height, /* height of texture */ - int rowStridePixel, /* row stride of input texture in pixels */ - unsigned short gfmt, /* glide format of input texture */ - unsigned short n64fmt,/* N64 format hi:format low:size */ - uint64 r_crc64 /* checksum hi:palette low:texture */ - ); +bool ext_ghq_dmptx(unsigned char *src, /* input texture (must be in 3Dfx Glide format) */ + int width, /* width of texture */ + int height, /* height of texture */ + int rowStridePixel, /* row stride of input texture in pixels */ + unsigned short gfmt, /* glide format of input texture */ + unsigned short n64fmt,/* N64 format hi:format low:size */ + uint64_t r_crc64 /* checksum hi:palette low:texture */ +); -boolean ext_ghq_reloadhirestex(); +bool ext_ghq_reloadhirestex(); #endif /* TXFILTER_DLL */ - -#endif /* __EXT_TXFILTER_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters.cpp index b46dcb566..c560ef281 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters.cpp @@ -1,25 +1,16 @@ -/* -Copyright (C) 2003 Rice1964 - -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-1307, USA. - -*/ - -/* Copyright (C) 2007 Hiroshi Morii - * Modified for the Texture Filtering library - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include "TextureFilters.h" @@ -35,210 +26,209 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void Texture2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint32 *pDst1, *pDst2; - uint32 *pSrc, *pSrc2; - uint32 nWidth = width; - uint32 nHeight = height; + uint32 *pDst1, *pDst2; + uint32 *pSrc, *pSrc2; + uint32 nWidth = width; + uint32 nHeight = height; - uint32 b1; - uint32 g1; - uint32 r1; - uint32 a1; - uint32 b2; - uint32 g2; - uint32 r2; - uint32 a2; - uint32 b3; - uint32 g3; - uint32 r3; - uint32 a3; - uint32 b4; - uint32 g4; - uint32 r4; - uint32 a4; + uint32 b1; + uint32 g1; + uint32 r1; + uint32 a1; + uint32 b2; + uint32 g2; + uint32 r2; + uint32 a2; + uint32 b3; + uint32 g3; + uint32 r3; + uint32 a3; + uint32 b4; + uint32 g4; + uint32 r4; + uint32 a4; - uint32 xSrc; - uint32 ySrc; + uint32 xSrc; + uint32 ySrc; - for (ySrc = 0; ySrc < nHeight; ySrc++) - { - pSrc = (uint32*)(((uint8*)srcPtr)+ySrc*srcPitch); - pSrc2 = (uint32*)(((uint8*)srcPtr)+(ySrc+1)*srcPitch); - pDst1 = (uint32*)(((uint8*)dstPtr)+(ySrc*2)*dstPitch); - pDst2 = (uint32*)(((uint8*)dstPtr)+(ySrc*2+1)*dstPitch); - - for (xSrc = 0; xSrc < nWidth; xSrc++) + for (ySrc = 0; ySrc < nHeight; ySrc++) { - b1 = (pSrc[xSrc]>>0)&0xFF; - g1 = (pSrc[xSrc]>>8)&0xFF; - r1 = (pSrc[xSrc]>>16)&0xFF; - a1 = (pSrc[xSrc]>>24)&0xFF; + pSrc = (uint32*)(((uint8*)srcPtr) + ySrc*srcPitch); + pSrc2 = (uint32*)(((uint8*)srcPtr) + (ySrc + 1)*srcPitch); + pDst1 = (uint32*)(((uint8*)dstPtr) + (ySrc * 2)*dstPitch); + pDst2 = (uint32*)(((uint8*)dstPtr) + (ySrc * 2 + 1)*dstPitch); - // Pixel 1 - pDst1[xSrc*2] = pSrc[xSrc]; + for (xSrc = 0; xSrc < nWidth; xSrc++) + { + b1 = (pSrc[xSrc] >> 0) & 0xFF; + g1 = (pSrc[xSrc] >> 8) & 0xFF; + r1 = (pSrc[xSrc] >> 16) & 0xFF; + a1 = (pSrc[xSrc] >> 24) & 0xFF; - // Pixel 2 - if( xSrc>0)&0xFF; - g2 = (pSrc[xSrc+1]>>8)&0xFF; - r2 = (pSrc[xSrc+1]>>16)&0xFF; - a2 = (pSrc[xSrc+1]>>24)&0xFF; - pDst1[xSrc*2+1] = DWORD_MAKE((r1+r2)/2, (g1+g2)/2, (b1+b2)/2, (a1+a2)/2); - } - else - pDst1[xSrc*2+1] = pSrc[xSrc]; + // Pixel 1 + pDst1[xSrc * 2] = pSrc[xSrc]; - // Pixel 3 - if( ySrc>0)&0xFF; - g3 = (pSrc2[xSrc]>>8)&0xFF; - r3 = (pSrc2[xSrc]>>16)&0xFF; - a3 = (pSrc2[xSrc]>>24)&0xFF; - pDst2[xSrc*2] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2); - if( xSrc>0)&0xFF; - g4 = (pSrc2[xSrc+1]>>8)&0xFF; - r4 = (pSrc2[xSrc+1]>>16)&0xFF; - a4 = (pSrc2[xSrc+1]>>24)&0xFF; - // Pixel 4 - pDst2[xSrc*2+1] = DWORD_MAKE((r1+r2+r3+r4)/4, (g1+g2+g3+g4)/4, (b1+b2+b3+b4)/4, (a1+a2+a3+a4)/4); + // Pixel 2 + if (xSrc < nWidth - 1) + { + b2 = (pSrc[xSrc + 1] >> 0) & 0xFF; + g2 = (pSrc[xSrc + 1] >> 8) & 0xFF; + r2 = (pSrc[xSrc + 1] >> 16) & 0xFF; + a2 = (pSrc[xSrc + 1] >> 24) & 0xFF; + pDst1[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2); + } + else + pDst1[xSrc * 2 + 1] = pSrc[xSrc]; + + // Pixel 3 + if (ySrc < nHeight - 1) + { + b3 = (pSrc2[xSrc] >> 0) & 0xFF; + g3 = (pSrc2[xSrc] >> 8) & 0xFF; + r3 = (pSrc2[xSrc] >> 16) & 0xFF; + a3 = (pSrc2[xSrc] >> 24) & 0xFF; + pDst2[xSrc * 2] = DWORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2); + if (xSrc < nWidth - 1) + { + b4 = (pSrc2[xSrc + 1] >> 0) & 0xFF; + g4 = (pSrc2[xSrc + 1] >> 8) & 0xFF; + r4 = (pSrc2[xSrc + 1] >> 16) & 0xFF; + a4 = (pSrc2[xSrc + 1] >> 24) & 0xFF; + // Pixel 4 + pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2 + r3 + r4) / 4, (g1 + g2 + g3 + g4) / 4, (b1 + b2 + b3 + b4) / 4, (a1 + a2 + a3 + a4) / 4); + } + else + { + // Pixel 4 + pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2); + } + } + else + { + // Pixel 3 + pDst2[xSrc * 2] = pSrc[xSrc]; + // Pixel 4 + if (xSrc < nWidth - 1) + { + pDst2[xSrc * 2 + 1] = DWORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2); + } + else + { + pDst2[xSrc * 2 + 1] = pSrc[xSrc]; + } + } } - else - { - // Pixel 4 - pDst2[xSrc*2+1] = DWORD_MAKE((r1+r3)/2, (g1+g3)/2, (b1+b3)/2, (a1+a3)/2); - } - } - else - { - // Pixel 3 - pDst2[xSrc*2] = pSrc[xSrc]; - // Pixel 4 - if( xSrc> 0)&0xF; - g1 = (pSrc[xSrc]>> 4)&0xF; - r1 = (pSrc[xSrc]>> 8)&0xF; - a1 = (pSrc[xSrc]>>12)&0xF; + pSrc = (uint16*)(((uint8*)srcPtr) + ySrc*srcPitch); + pSrc2 = (uint16*)(((uint8*)srcPtr) + (ySrc + 1)*srcPitch); + pDst1 = (uint16*)(((uint8*)dstPtr) + (ySrc * 2)*dstPitch); + pDst2 = (uint16*)(((uint8*)dstPtr) + (ySrc * 2 + 1)*dstPitch); - if( xSrc> 0)&0xF; - g2 = (pSrc[xSrc+1]>> 4)&0xF; - r2 = (pSrc[xSrc+1]>> 8)&0xF; - a2 = (pSrc[xSrc+1]>>12)&0xF; - } - - if( ySrc> 0)&0xF; - g3 = (pSrc2[xSrc]>> 4)&0xF; - r3 = (pSrc2[xSrc]>> 8)&0xF; - a3 = (pSrc2[xSrc]>>12)&0xF; - if( xSrc> 0)&0xF; - g4 = (pSrc2[xSrc+1]>> 4)&0xF; - r4 = (pSrc2[xSrc+1]>> 8)&0xF; - a4 = (pSrc2[xSrc+1]>>12)&0xF; + b1 = (pSrc[xSrc] >> 0) & 0xF; + g1 = (pSrc[xSrc] >> 4) & 0xF; + r1 = (pSrc[xSrc] >> 8) & 0xF; + a1 = (pSrc[xSrc] >> 12) & 0xF; + + if (xSrc < nWidth - 1) + { + b2 = (pSrc[xSrc + 1] >> 0) & 0xF; + g2 = (pSrc[xSrc + 1] >> 4) & 0xF; + r2 = (pSrc[xSrc + 1] >> 8) & 0xF; + a2 = (pSrc[xSrc + 1] >> 12) & 0xF; + } + + if (ySrc < nHeight - 1) + { + b3 = (pSrc2[xSrc] >> 0) & 0xF; + g3 = (pSrc2[xSrc] >> 4) & 0xF; + r3 = (pSrc2[xSrc] >> 8) & 0xF; + a3 = (pSrc2[xSrc] >> 12) & 0xF; + if (xSrc < nWidth - 1) + { + b4 = (pSrc2[xSrc + 1] >> 0) & 0xF; + g4 = (pSrc2[xSrc + 1] >> 4) & 0xF; + r4 = (pSrc2[xSrc + 1] >> 8) & 0xF; + a4 = (pSrc2[xSrc + 1] >> 12) & 0xF; + } + } + + // Pixel 1 + pDst1[xSrc * 2] = pSrc[xSrc]; + + // Pixel 2 + if (xSrc < nWidth - 1) + { + pDst1[xSrc * 2 + 1] = WORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2); + } + else + pDst1[xSrc * 2 + 1] = pSrc[xSrc]; + + // Pixel 3 + if (ySrc < nHeight - 1) + { + pDst2[xSrc * 2] = WORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2); + } + else + pDst2[xSrc * 2] = pSrc[xSrc]; + + // Pixel 4 + if (xSrc < nWidth - 1) + { + if (ySrc < nHeight - 1) + { + pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r2 + r3 + r4) / 4, (g1 + g2 + g3 + g4) / 4, (b1 + b2 + b3 + b4) / 4, (a1 + a2 + a3 + a4) / 4); + } + else + { + pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r2) / 2, (g1 + g2) / 2, (b1 + b2) / 2, (a1 + a2) / 2); + } + } + else + { + if (ySrc < nHeight - 1) + { + pDst2[xSrc * 2 + 1] = WORD_MAKE((r1 + r3) / 2, (g1 + g3) / 2, (b1 + b3) / 2, (a1 + a3) / 2); + } + else + pDst2[xSrc * 2 + 1] = pSrc[xSrc]; + } } - } - - // Pixel 1 - pDst1[xSrc*2] = pSrc[xSrc]; - - // Pixel 2 - if( xSrc (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) { - val[z]= ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4; - if (val[z] > 0xFF) val[z] = 0xFF; - } else { - val[z] = t5; - } - } - _dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24); + switch (filter) + { + case SHARP_FILTER_2: + mul1 = 1; + mul2 = 8; + mul3 = 12; + shift4 = 2; + break; + case SHARP_FILTER_1: + default: + mul1 = 1; + mul2 = 8; + mul3 = 16; + shift4 = 3; + break; } - // copy the ending pixel - _dest[srcwidth-1] = *(_src3 - 1); - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; + + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + + // copy the first row + memcpy(_dest, _src1, (srcwidth << 2)); _dest += srcwidth; - } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 2)); + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + // copy the first pixel + _dest[0] = *_src2; + // filter 2nd pixel to 1 pixel before last + for (x = 1; x < srcwidth - 1; x++) { + for (z = 0; z < 4; z++) { + t1 = *((uint8*)(_src1 + x - 1) + z); + t2 = *((uint8*)(_src1 + x) + z); + t3 = *((uint8*)(_src1 + x + 1) + z); + t4 = *((uint8*)(_src2 + x - 1) + z); + t5 = *((uint8*)(_src2 + x) + z); + t6 = *((uint8*)(_src2 + x + 1) + z); + t7 = *((uint8*)(_src3 + x - 1) + z); + t8 = *((uint8*)(_src3 + x) + z); + t9 = *((uint8*)(_src3 + x + 1) + z); + + if ((t5*mul2) > (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) { + val[z] = ((t5*mul3) - (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) >> shift4; + if (val[z] > 0xFF) val[z] = 0xFF; + } + else { + val[z] = t5; + } + } + _dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); + } + // copy the ending pixel + _dest[srcwidth - 1] = *(_src3 - 1); + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; + } + // copy the last row + memcpy(_dest, _src2, (srcwidth << 2)); } #if !_16BPP_HACK void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: for now we get away with copying the boundaries + // filter the boundaries if we face problems - uint16 mul1, mul2, mul3, shift4; + uint16 mul1, mul2, mul3, shift4; - uint32 x,y,z; - uint16 *_src1, *_src2, *_src3, *_dest; - uint16 val[4]; - uint16 t1,t2,t3,t4,t5,t6,t7,t8,t9; + uint32 x, y, z; + uint16 *_src1, *_src2, *_src3, *_dest; + uint16 val[4]; + uint16 t1, t2, t3, t4, t5, t6, t7, t8, t9; - switch( filter ) { - case SHARP_FILTER_2: - mul1=1; - mul2=8; - mul3=12; - shift4=2; - break; - case SHARP_FILTER_1: - default: - mul1=1; - mul2=8; - mul3=16; - shift4=3; - break; - } - - // setup rows - _src1 = src; - _src2 = _src1 + srcwidth; - _src3 = _src2 + srcwidth; - _dest = dest; - - // copy the first row - memcpy(_dest, _src1, (srcwidth << 1)); - _dest += srcwidth; - // filter 2nd row to 1 row before the last - for( y = 1; y < srcheight - 1; y++) { - // copy the first pixel - _dest[0] = *_src2; - // filter 2nd pixel to 1 pixel before last - for( x = 1; x < srcwidth - 1; x++) { - for( z = 0; z < 4; z++ ) { - /* Hiroshi Morii - * Read the entire 16bit pixel and then extract the A,R,G,B components. - */ - uint32 shift = z << 2; - t1 = ((*((uint16*)(_src1+x-1))) >> shift) & 0xF; - t2 = ((*((uint16*)(_src1+x ))) >> shift) & 0xF; - t3 = ((*((uint16*)(_src1+x+1))) >> shift) & 0xF; - t4 = ((*((uint16*)(_src2+x-1))) >> shift) & 0xF; - t5 = ((*((uint16*)(_src2+x ))) >> shift) & 0xF; - t6 = ((*((uint16*)(_src2+x+1))) >> shift) & 0xF; - t7 = ((*((uint16*)(_src3+x-1))) >> shift) & 0xF; - t8 = ((*((uint16*)(_src3+x ))) >> shift) & 0xF; - t9 = ((*((uint16*)(_src3+x+1))) >> shift) & 0xF; - - if( (t5*mul2) > (t1+t3+t7+t9+t2+t4+t6+t8)*mul1 ) { - val[z] = ((t5*mul3) - (t1+t3+t7+t9+t2+t4+t6+t8)*mul1)>>shift4; - if (val[z] > 0xF) val[z] = 0xF; - } else { - val[z] = t5; - } - } - _dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12); + switch (filter) { + case SHARP_FILTER_2: + mul1 = 1; + mul2 = 8; + mul3 = 12; + shift4 = 2; + break; + case SHARP_FILTER_1: + default: + mul1 = 1; + mul2 = 8; + mul3 = 16; + shift4 = 3; + break; } - // copy the ending pixel - _dest[srcwidth-1] = *(_src3 - 1); - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; + + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + + // copy the first row + memcpy(_dest, _src1, (srcwidth << 1)); _dest += srcwidth; - } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 1)); + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + // copy the first pixel + _dest[0] = *_src2; + // filter 2nd pixel to 1 pixel before last + for (x = 1; x < srcwidth - 1; x++) { + for (z = 0; z < 4; z++) { + /* Hiroshi Morii + * Read the entire 16bit pixel and then extract the A,R,G,B components. + */ + uint32 shift = z << 2; + t1 = ((*((uint16*)(_src1 + x - 1))) >> shift) & 0xF; + t2 = ((*((uint16*)(_src1 + x))) >> shift) & 0xF; + t3 = ((*((uint16*)(_src1 + x + 1))) >> shift) & 0xF; + t4 = ((*((uint16*)(_src2 + x - 1))) >> shift) & 0xF; + t5 = ((*((uint16*)(_src2 + x))) >> shift) & 0xF; + t6 = ((*((uint16*)(_src2 + x + 1))) >> shift) & 0xF; + t7 = ((*((uint16*)(_src3 + x - 1))) >> shift) & 0xF; + t8 = ((*((uint16*)(_src3 + x))) >> shift) & 0xF; + t9 = ((*((uint16*)(_src3 + x + 1))) >> shift) & 0xF; + + if ((t5*mul2) > (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) { + val[z] = ((t5*mul3) - (t1 + t3 + t7 + t9 + t2 + t4 + t6 + t8)*mul1) >> shift4; + if (val[z] > 0xF) val[z] = 0xF; + } + else { + val[z] = t5; + } + } + _dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12); + } + // copy the ending pixel + _dest[srcwidth - 1] = *(_src3 - 1); + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; + } + // copy the last row + memcpy(_dest, _src2, (srcwidth << 1)); } #endif /* !_16BPP_HACK */ @@ -409,294 +401,296 @@ void SharpFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *de */ void SmoothFilter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: for now we get away with copying the boundaries + // filter the boundaries if we face problems - uint32 mul1, mul2, mul3, shift4; + uint32 mul1, mul2, mul3, shift4; - uint32 x,y,z; - uint32 *_src1, *_src2, *_src3, *_dest; - uint32 val[4]; - uint32 t1,t2,t3,t4,t5,t6,t7,t8,t9; + uint32 x, y, z; + uint32 *_src1, *_src2, *_src3, *_dest; + uint32 val[4]; + uint32 t1, t2, t3, t4, t5, t6, t7, t8, t9; - switch( filter ) { - case SMOOTH_FILTER_4: - mul1=1; - mul2=2; - mul3=4; - shift4=4; - break; - case SMOOTH_FILTER_3: - mul1=1; - mul2=1; - mul3=8; - shift4=4; - break; - case SMOOTH_FILTER_2: - mul1=1; - mul2=1; - mul3=2; - shift4=2; - break; - case SMOOTH_FILTER_1: - default: - mul1=1; - mul2=1; - mul3=6; - shift4=3; - break; - } - - switch (filter) { - case SMOOTH_FILTER_3: - case SMOOTH_FILTER_4: - // setup rows - _src1 = src; - _src2 = _src1 + srcwidth; - _src3 = _src2 + srcwidth; - _dest = dest; - // copy the first row - memcpy(_dest, _src1, (srcwidth << 2)); - _dest += srcwidth; - // filter 2nd row to 1 row before the last - for (y = 1; y < srcheight - 1; y++){ - // copy the first pixel - _dest[0] = _src2[0]; - // filter 2nd pixel to 1 pixel before last - for (x = 1; x < srcwidth - 1; x++) { - for (z = 0; z < 4; z++ ) { - t1 = *((uint8*)(_src1+x-1)+z); - t2 = *((uint8*)(_src1+x )+z); - t3 = *((uint8*)(_src1+x+1)+z); - t4 = *((uint8*)(_src2+x-1)+z); - t5 = *((uint8*)(_src2+x )+z); - t6 = *((uint8*)(_src2+x+1)+z); - t7 = *((uint8*)(_src3+x-1)+z); - t8 = *((uint8*)(_src3+x )+z); - t9 = *((uint8*)(_src3+x+1)+z); - /* the component value must not overflow 0xFF */ - val[z] = ((t1+t3+t7+t9)*mul1+((t2+t4+t6+t8)*mul2)+(t5*mul3))>>shift4; - if (val[z] > 0xFF) val[z] = 0xFF; - } - _dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24); - } - // copy the ending pixel - _dest[srcwidth-1] = *(_src3 - 1); - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; - _dest += srcwidth; + switch (filter) { + case SMOOTH_FILTER_4: + mul1 = 1; + mul2 = 2; + mul3 = 4; + shift4 = 4; + break; + case SMOOTH_FILTER_3: + mul1 = 1; + mul2 = 1; + mul3 = 8; + shift4 = 4; + break; + case SMOOTH_FILTER_2: + mul1 = 1; + mul2 = 1; + mul3 = 2; + shift4 = 2; + break; + case SMOOTH_FILTER_1: + default: + mul1 = 1; + mul2 = 1; + mul3 = 6; + shift4 = 3; + break; } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 2)); - break; - case SMOOTH_FILTER_1: - case SMOOTH_FILTER_2: - default: - // setup rows - _src1 = src; - _src2 = _src1 + srcwidth; - _src3 = _src2 + srcwidth; - _dest = dest; - // copy the first row - memcpy(_dest, _src1, (srcwidth << 2)); - _dest += srcwidth; - // filter 2nd row to 1 row before the last - for (y = 1; y < srcheight - 1; y++) { - // filter 1st pixel to the last - if (y & 1) { - for( x = 0; x < srcwidth; x++) { - for( z = 0; z < 4; z++ ) { - t2 = *((uint8*)(_src1+x )+z); - t5 = *((uint8*)(_src2+x )+z); - t8 = *((uint8*)(_src3+x )+z); - /* the component value must not overflow 0xFF */ - val[z] = ((t2+t8)*mul2+(t5*mul3))>>shift4; - if (val[z] > 0xFF) val[z] = 0xFF; - } - _dest[x] = val[0]|(val[1]<<8)|(val[2]<<16)|(val[3]<<24); + + switch (filter) { + case SMOOTH_FILTER_3: + case SMOOTH_FILTER_4: + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + // copy the first row + memcpy(_dest, _src1, (srcwidth << 2)); + _dest += srcwidth; + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + // copy the first pixel + _dest[0] = _src2[0]; + // filter 2nd pixel to 1 pixel before last + for (x = 1; x < srcwidth - 1; x++) { + for (z = 0; z < 4; z++) { + t1 = *((uint8*)(_src1 + x - 1) + z); + t2 = *((uint8*)(_src1 + x) + z); + t3 = *((uint8*)(_src1 + x + 1) + z); + t4 = *((uint8*)(_src2 + x - 1) + z); + t5 = *((uint8*)(_src2 + x) + z); + t6 = *((uint8*)(_src2 + x + 1) + z); + t7 = *((uint8*)(_src3 + x - 1) + z); + t8 = *((uint8*)(_src3 + x) + z); + t9 = *((uint8*)(_src3 + x + 1) + z); + /* the component value must not overflow 0xFF */ + val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4; + if (val[z] > 0xFF) val[z] = 0xFF; + } + _dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); + } + // copy the ending pixel + _dest[srcwidth - 1] = *(_src3 - 1); + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; } - } else { - memcpy(_dest, _src2, (srcwidth << 2)); - } - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; - _dest += srcwidth; + // copy the last row + memcpy(_dest, _src2, (srcwidth << 2)); + break; + case SMOOTH_FILTER_1: + case SMOOTH_FILTER_2: + default: + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + // copy the first row + memcpy(_dest, _src1, (srcwidth << 2)); + _dest += srcwidth; + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + // filter 1st pixel to the last + if (y & 1) { + for (x = 0; x < srcwidth; x++) { + for (z = 0; z < 4; z++) { + t2 = *((uint8*)(_src1 + x) + z); + t5 = *((uint8*)(_src2 + x) + z); + t8 = *((uint8*)(_src3 + x) + z); + /* the component value must not overflow 0xFF */ + val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4; + if (val[z] > 0xFF) val[z] = 0xFF; + } + _dest[x] = val[0] | (val[1] << 8) | (val[2] << 16) | (val[3] << 24); + } + } + else { + memcpy(_dest, _src2, (srcwidth << 2)); + } + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; + } + // copy the last row + memcpy(_dest, _src2, (srcwidth << 2)); + break; } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 2)); - break; - } } #if !_16BPP_HACK void SmoothFilter_4444(uint16 *src, uint32 srcwidth, uint32 srcheight, uint16 *dest, uint32 filter) { - // NOTE: for now we get away with copying the boundaries - // filter the boundaries if we face problems + // NOTE: for now we get away with copying the boundaries + // filter the boundaries if we face problems - uint16 mul1, mul2, mul3, shift4; + uint16 mul1, mul2, mul3, shift4; - uint32 x,y,z; - uint16 *_src1, *_src2, *_src3, *_dest; - uint16 val[4]; - uint16 t1,t2,t3,t4,t5,t6,t7,t8,t9; + uint32 x, y, z; + uint16 *_src1, *_src2, *_src3, *_dest; + uint16 val[4]; + uint16 t1, t2, t3, t4, t5, t6, t7, t8, t9; - switch( filter ) { - case SMOOTH_FILTER_4: - mul1=1; - mul2=2; - mul3=4; - shift4=4; - break; - case SMOOTH_FILTER_3: - mul1=1; - mul2=1; - mul3=8; - shift4=4; - break; - case SMOOTH_FILTER_2: - mul1=1; - mul2=1; - mul3=2; - shift4=2; - break; - case SMOOTH_FILTER_1: - default: - mul1=1; - mul2=1; - mul3=6; - shift4=3; - break; - } - - switch (filter) { - case SMOOTH_FILTER_3: - case SMOOTH_FILTER_4: - // setup rows - _src1 = src; - _src2 = _src1 + srcwidth; - _src3 = _src2 + srcwidth; - _dest = dest; - // copy the first row - memcpy(_dest, _src1, (srcwidth << 1)); - _dest += srcwidth; - // filter 2nd row to 1 row before the last - for (y = 1; y < srcheight - 1; y++) { - // copy the first pixel - _dest[0] = *_src2; - // filter 2nd pixel to 1 pixel before last - for (x = 1; x < srcwidth - 1; x++) { - for (z = 0; z < 4; z++ ) { - /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ - uint32 shift = z << 2; - t1 = ((*(uint16*)(_src1+x-1)) >> shift) & 0xF; - t2 = ((*(uint16*)(_src1+x )) >> shift) & 0xF; - t3 = ((*(uint16*)(_src1+x+1)) >> shift) & 0xF; - t4 = ((*(uint16*)(_src2+x-1)) >> shift) & 0xF; - t5 = ((*(uint16*)(_src2+x )) >> shift) & 0xF; - t6 = ((*(uint16*)(_src2+x+1)) >> shift) & 0xF; - t7 = ((*(uint16*)(_src3+x-1)) >> shift) & 0xF; - t8 = ((*(uint16*)(_src3+x )) >> shift) & 0xF; - t9 = ((*(uint16*)(_src3+x+1)) >> shift) & 0xF; - /* the component value must not overflow 0xF */ - val[z] = ((t1+t3+t7+t9)*mul1+((t2+t4+t6+t8)*mul2)+(t5*mul3))>>shift4; - if (val[z] > 0xF) val[z] = 0xF; - } - _dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12); - } - // copy the ending pixel - _dest[srcwidth-1] = *(_src3 - 1); - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; - _dest += srcwidth; + switch (filter) { + case SMOOTH_FILTER_4: + mul1 = 1; + mul2 = 2; + mul3 = 4; + shift4 = 4; + break; + case SMOOTH_FILTER_3: + mul1 = 1; + mul2 = 1; + mul3 = 8; + shift4 = 4; + break; + case SMOOTH_FILTER_2: + mul1 = 1; + mul2 = 1; + mul3 = 2; + shift4 = 2; + break; + case SMOOTH_FILTER_1: + default: + mul1 = 1; + mul2 = 1; + mul3 = 6; + shift4 = 3; + break; } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 1)); - break; - case SMOOTH_FILTER_1: - case SMOOTH_FILTER_2: - default: - // setup rows - _src1 = src; - _src2 = _src1 + srcwidth; - _src3 = _src2 + srcwidth; - _dest = dest; - // copy the first row - memcpy(_dest, _src1, (srcwidth << 1)); - _dest += srcwidth; - // filter 2nd row to 1 row before the last - for( y = 1; y < srcheight - 1; y++) { - if (y & 1) { - for( x = 0; x < srcwidth; x++) { - for( z = 0; z < 4; z++ ) { - /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ - uint32 shift = z << 2; - t2 = ((*(uint16*)(_src1+x)) >> shift) & 0xF; - t5 = ((*(uint16*)(_src2+x)) >> shift) & 0xF; - t8 = ((*(uint16*)(_src3+x)) >> shift) & 0xF; - /* the component value must not overflow 0xF */ - val[z] = ((t2+t8)*mul2+(t5*mul3))>>shift4; - if (val[z] > 0xF) val[z] = 0xF; - } - _dest[x] = val[0]|(val[1]<<4)|(val[2]<<8)|(val[3]<<12); + + switch (filter) { + case SMOOTH_FILTER_3: + case SMOOTH_FILTER_4: + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + // copy the first row + memcpy(_dest, _src1, (srcwidth << 1)); + _dest += srcwidth; + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + // copy the first pixel + _dest[0] = *_src2; + // filter 2nd pixel to 1 pixel before last + for (x = 1; x < srcwidth - 1; x++) { + for (z = 0; z < 4; z++) { + /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ + uint32 shift = z << 2; + t1 = ((*(uint16*)(_src1 + x - 1)) >> shift) & 0xF; + t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF; + t3 = ((*(uint16*)(_src1 + x + 1)) >> shift) & 0xF; + t4 = ((*(uint16*)(_src2 + x - 1)) >> shift) & 0xF; + t5 = ((*(uint16*)(_src2 + x)) >> shift) & 0xF; + t6 = ((*(uint16*)(_src2 + x + 1)) >> shift) & 0xF; + t7 = ((*(uint16*)(_src3 + x - 1)) >> shift) & 0xF; + t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF; + t9 = ((*(uint16*)(_src3 + x + 1)) >> shift) & 0xF; + /* the component value must not overflow 0xF */ + val[z] = ((t1 + t3 + t7 + t9)*mul1 + ((t2 + t4 + t6 + t8)*mul2) + (t5*mul3)) >> shift4; + if (val[z] > 0xF) val[z] = 0xF; + } + _dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12); + } + // copy the ending pixel + _dest[srcwidth - 1] = *(_src3 - 1); + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; } - } else { - memcpy(_dest, _src2, (srcwidth << 1)); - } - // next row - _src1 += srcwidth; - _src2 += srcwidth; - _src3 += srcwidth; - _dest += srcwidth; + // copy the last row + memcpy(_dest, _src2, (srcwidth << 1)); + break; + case SMOOTH_FILTER_1: + case SMOOTH_FILTER_2: + default: + // setup rows + _src1 = src; + _src2 = _src1 + srcwidth; + _src3 = _src2 + srcwidth; + _dest = dest; + // copy the first row + memcpy(_dest, _src1, (srcwidth << 1)); + _dest += srcwidth; + // filter 2nd row to 1 row before the last + for (y = 1; y < srcheight - 1; y++) { + if (y & 1) { + for (x = 0; x < srcwidth; x++) { + for (z = 0; z < 4; z++) { + /* Read the entire 16bit pixel and then extract the A,R,G,B components. */ + uint32 shift = z << 2; + t2 = ((*(uint16*)(_src1 + x)) >> shift) & 0xF; + t5 = ((*(uint16*)(_src2 + x)) >> shift) & 0xF; + t8 = ((*(uint16*)(_src3 + x)) >> shift) & 0xF; + /* the component value must not overflow 0xF */ + val[z] = ((t2 + t8)*mul2 + (t5*mul3)) >> shift4; + if (val[z] > 0xF) val[z] = 0xF; + } + _dest[x] = val[0] | (val[1] << 4) | (val[2] << 8) | (val[3] << 12); + } + } + else { + memcpy(_dest, _src2, (srcwidth << 1)); + } + // next row + _src1 += srcwidth; + _src2 += srcwidth; + _src3 += srcwidth; + _dest += srcwidth; + } + // copy the last row + memcpy(_dest, _src2, (srcwidth << 1)); + break; } - // copy the last row - memcpy(_dest, _src2, (srcwidth << 1)); - break; - } } #endif /* !_16BPP_HACK */ void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, uint32 filter) { - switch (filter & ENHANCEMENT_MASK) { - case HQ4X_ENHANCEMENT: - hq4x_8888((uint8*)src, (uint8*)dest, srcwidth, srcheight, srcwidth, (srcwidth << 4)); - return; - case HQ2X_ENHANCEMENT: - hq2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); - return; - case HQ2XS_ENHANCEMENT: - hq2xS_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); - return; - case LQ2X_ENHANCEMENT: - lq2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); - return; - case LQ2XS_ENHANCEMENT: - lq2xS_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); - return; - case X2SAI_ENHANCEMENT: - Super2xSaI_8888((uint32*)src, (uint32*)dest, srcwidth, srcheight, srcwidth); - return; - case X2_ENHANCEMENT: - Texture2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); - return; - } + switch (filter & ENHANCEMENT_MASK) { + case HQ4X_ENHANCEMENT: + hq4x_8888((uint8*)src, (uint8*)dest, srcwidth, srcheight, srcwidth, (srcwidth << 4)); + return; + case HQ2X_ENHANCEMENT: + hq2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); + return; + case HQ2XS_ENHANCEMENT: + hq2xS_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); + return; + case LQ2X_ENHANCEMENT: + lq2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); + return; + case LQ2XS_ENHANCEMENT: + lq2xS_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); + return; + case X2SAI_ENHANCEMENT: + Super2xSaI_8888((uint32*)src, (uint32*)dest, srcwidth, srcheight, srcwidth); + return; + case X2_ENHANCEMENT: + Texture2x_32((uint8*)src, (srcwidth << 2), (uint8*)dest, (srcwidth << 3), srcwidth, srcheight); + return; + } - switch (filter & (SMOOTH_FILTER_MASK|SHARP_FILTER_MASK)) { - case SMOOTH_FILTER_1: - case SMOOTH_FILTER_2: - case SMOOTH_FILTER_3: - case SMOOTH_FILTER_4: - SmoothFilter_8888((uint32*)src, srcwidth, srcheight, (uint32*)dest, (filter & SMOOTH_FILTER_MASK)); - return; - case SHARP_FILTER_1: - case SHARP_FILTER_2: - SharpFilter_8888((uint32*)src, srcwidth, srcheight, (uint32*)dest, (filter & SHARP_FILTER_MASK)); - return; - } -} + switch (filter & (SMOOTH_FILTER_MASK | SHARP_FILTER_MASK)) { + case SMOOTH_FILTER_1: + case SMOOTH_FILTER_2: + case SMOOTH_FILTER_3: + case SMOOTH_FILTER_4: + SmoothFilter_8888((uint32*)src, srcwidth, srcheight, (uint32*)dest, (filter & SMOOTH_FILTER_MASK)); + return; + case SHARP_FILTER_1: + case SHARP_FILTER_2: + SharpFilter_8888((uint32*)src, srcwidth, srcheight, (uint32*)dest, (filter & SHARP_FILTER_MASK)); + return; + } +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters.h b/Source/Project64-video/TextureEnhancer/TextureFilters.h index 7830eac5f..72b788cec 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters.h @@ -1,26 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TEXTUREFILTERS_H__ #define __TEXTUREFILTERS_H__ @@ -33,7 +23,7 @@ #include "TxInternal.h" -/* enhancers */ + /* enhancers */ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); @@ -58,7 +48,7 @@ void filter_8888(uint32 *src, uint32 srcwidth, uint32 srcheight, uint32 *dest, u void hq4x_init(void); void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); -void hq4x_565 (unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); +void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int SrcPPL, int BpL); void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); void hq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); @@ -68,8 +58,8 @@ void lq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in void Super2xSaI_4444(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); void Super2xSaI_1555(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); -void Super2xSaI_565 (uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); -void Super2xSaI_8 (uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, uint32 pitch); +void Super2xSaI_565(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height, uint32 pitch); +void Super2xSaI_8(uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, uint32 pitch); void Texture2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height); diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp index d7e8305ff..e35c998da 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_2xsai.cpp @@ -1,28 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* Based on Derek Liauw Kie Fa and Rice1964 Super2xSaI code */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "TextureFilters.h" #define GET_RESULT(A, B, C, D) ((A != C || A != D) - (B != C || B != D)) @@ -36,14 +24,14 @@ void Super2xSaI_8888(uint32 *srcPtr, uint32 *destPtr, uint32 width, uint32 heigh #define SAI_INTERPOLATE SAI_INTERPOLATE_8888 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8888 - uint32 destWidth = width << 1; - - uint32 color4, color5, color6; - uint32 color1, color2, color3; - uint32 colorA0, colorA1, colorA2, colorA3; - uint32 colorB0, colorB1, colorB2, colorB3; - uint32 colorS1, colorS2; - uint32 product1a, product1b, product2a, product2b; + uint32 destWidth = width << 1; + + uint32 color4, color5, color6; + uint32 color1, color2, color3; + uint32 colorA0, colorA1, colorA2, colorA3; + uint32 colorB0, colorB1, colorB2, colorB3; + uint32 colorS1, colorS2; + uint32 product1a, product1b, product2a, product2b; #include "TextureFilters_2xsai.h" @@ -61,15 +49,15 @@ void Super2xSaI_4444(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 heigh #define SAI_INTERPOLATE SAI_INTERPOLATE_4444 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_4444 - uint32 destWidth = width << 1; - uint32 destHeight = height << 1; + uint32 destWidth = width << 1; + uint32 destHeight = height << 1; - uint16 color4, color5, color6; - uint16 color1, color2, color3; - uint16 colorA0, colorA1, colorA2, colorA3; - uint16 colorB0, colorB1, colorB2, colorB3; - uint16 colorS1, colorS2; - uint16 product1a, product1b, product2a, product2b; + uint16 color4, color5, color6; + uint16 color1, color2, color3; + uint16 colorA0, colorA1, colorA2, colorA3; + uint16 colorB0, colorB1, colorB2, colorB3; + uint16 colorS1, colorS2; + uint16 product1a, product1b, product2a, product2b; #include "TextureFilters_2xsai.h" @@ -86,15 +74,15 @@ void Super2xSaI_1555(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 heigh #define SAI_INTERPOLATE SAI_INTERPOLATE_1555 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_1555 - uint32 destWidth = width << 1; - uint32 destHeight = height << 1; + uint32 destWidth = width << 1; + uint32 destHeight = height << 1; - uint16 color4, color5, color6; - uint16 color1, color2, color3; - uint16 colorA0, colorA1, colorA2, colorA3; - uint16 colorB0, colorB1, colorB2, colorB3; - uint16 colorS1, colorS2; - uint16 product1a, product1b, product2a, product2b; + uint16 color4, color5, color6; + uint16 color1, color2, color3; + uint16 colorA0, colorA1, colorA2, colorA3; + uint16 colorB0, colorB1, colorB2, colorB3; + uint16 colorS1, colorS2; + uint16 product1a, product1b, product2a, product2b; #include "TextureFilters_2xsai.h" @@ -111,15 +99,15 @@ void Super2xSaI_565(uint16 *srcPtr, uint16 *destPtr, uint32 width, uint32 height #define SAI_INTERPOLATE SAI_INTERPOLATE_565 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_565 - uint32 destWidth = width << 1; - uint32 destHeight = height << 1; + uint32 destWidth = width << 1; + uint32 destHeight = height << 1; - uint16 color4, color5, color6; - uint16 color1, color2, color3; - uint16 colorA0, colorA1, colorA2, colorA3; - uint16 colorB0, colorB1, colorB2, colorB3; - uint16 colorS1, colorS2; - uint16 product1a, product1b, product2a, product2b; + uint16 color4, color5, color6; + uint16 color1, color2, color3; + uint16 colorA0, colorA1, colorA2, colorA3; + uint16 colorB0, colorB1, colorB2, colorB3; + uint16 colorS1, colorS2; + uint16 product1a, product1b, product2a, product2b; #include "TextureFilters_2xsai.h" @@ -136,19 +124,19 @@ void Super2xSaI_8(uint8 *srcPtr, uint8 *destPtr, uint32 width, uint32 height, ui #define SAI_INTERPOLATE SAI_INTERPOLATE_8 #define SAI_Q_INTERPOLATE SAI_Q_INTERPOLATE_8 - uint32 destWidth = width << 1; - uint32 destHeight = height << 1; + uint32 destWidth = width << 1; + uint32 destHeight = height << 1; - uint8 color4, color5, color6; - uint8 color1, color2, color3; - uint8 colorA0, colorA1, colorA2, colorA3; - uint8 colorB0, colorB1, colorB2, colorB3; - uint8 colorS1, colorS2; - uint8 product1a, product1b, product2a, product2b; + uint8 color4, color5, color6; + uint8 color1, color2, color3; + uint8 colorA0, colorA1, colorA2, colorA3; + uint8 colorB0, colorB1, colorB2, colorB3; + uint8 colorS1, colorS2; + uint8 product1a, product1b, product2a, product2b; #include "TextureFilters_2xsai.h" #undef SAI_INTERPOLATE #undef SAI_Q_INTERPOLATE } -#endif /* !_16BPP_HACK */ +#endif /* !_16BPP_HACK */ \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp index 33cb99530..b04fecb32 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.cpp @@ -1,28 +1,17 @@ -/* -Copyright (C) 2003 Rice1964 - -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-1307, USA. - -*/ - -/* Copyright (C) 2007 Hiroshi Morii - * Modified for the Texture Filtering library - */ - -/* 2007 Mudlord - Added hq2xS lq2xS filters */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2007 Mudlord * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "TextureFilters.h" /************************************************************************/ @@ -44,80 +33,80 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static uint16 hq2x_interp_16_521(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*2 + INTERP_16_MASK_1_3(p3)*1) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*2 + INTERP_16_MASK_SHIFT_2_4(p3)*1) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 5 + INTERP_16_MASK_1_3(p2) * 2 + INTERP_16_MASK_1_3(p3) * 1) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 5 + INTERP_16_MASK_SHIFT_2_4(p2) * 2 + INTERP_16_MASK_SHIFT_2_4(p3) * 1) / 8); } static uint16 hq2x_interp_16_332(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)*2) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 3 + INTERP_16_MASK_1_3(p2) * 3 + INTERP_16_MASK_1_3(p3) * 2) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 3 + INTERP_16_MASK_SHIFT_2_4(p2) * 3 + INTERP_16_MASK_SHIFT_2_4(p3) * 2) / 8); } static uint16 hq2x_interp_16_611(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*6 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*6 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 6 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 6 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 8); } static uint16 hq2x_interp_16_71(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*7 + INTERP_16_MASK_1_3(p2)) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*7 + INTERP_16_MASK_SHIFT_2_4(p2)) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 7 + INTERP_16_MASK_1_3(p2)) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 7 + INTERP_16_MASK_SHIFT_2_4(p2)) / 8); } static uint16 hq2x_interp_16_211(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*2 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 4) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*2 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 4); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 2 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 4) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 2 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 4); } static uint16 hq2x_interp_16_772(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3(((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2))*7 + INTERP_16_MASK_1_3(p3)*2) / 16) - | INTERP_16_MASK_SHIFTBACK_2_4(((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2))*7 + INTERP_16_MASK_SHIFT_2_4(p3)*2) / 16); + return INTERP_16_MASK_1_3(((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2)) * 7 + INTERP_16_MASK_1_3(p3) * 2) / 16) + | INTERP_16_MASK_SHIFTBACK_2_4(((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2)) * 7 + INTERP_16_MASK_SHIFT_2_4(p3) * 2) / 16); } static uint16 hq2x_interp_16_11(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2)) / 2) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2)) / 2); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) + INTERP_16_MASK_1_3(p2)) / 2) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) + INTERP_16_MASK_SHIFT_2_4(p2)) / 2); } static uint16 hq2x_interp_16_31(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*3 + INTERP_16_MASK_1_3(p2)) / 4) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*3 + INTERP_16_MASK_SHIFT_2_4(p2)) / 4); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 3 + INTERP_16_MASK_1_3(p2)) / 4) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 3 + INTERP_16_MASK_SHIFT_2_4(p2)) / 4); } static uint16 hq2x_interp_16_1411(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*14 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 16) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*14 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 16); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 14 + INTERP_16_MASK_1_3(p2) + INTERP_16_MASK_1_3(p3)) / 16) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 14 + INTERP_16_MASK_SHIFT_2_4(p2) + INTERP_16_MASK_SHIFT_2_4(p3)) / 16); } static uint16 hq2x_interp_16_431(uint16 p1, uint16 p2, uint16 p3) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*4 + INTERP_16_MASK_1_3(p2)*3 + INTERP_16_MASK_1_3(p3)) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*4 + INTERP_16_MASK_SHIFT_2_4(p2)*3 + INTERP_16_MASK_SHIFT_2_4(p3)) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 4 + INTERP_16_MASK_1_3(p2) * 3 + INTERP_16_MASK_1_3(p3)) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 4 + INTERP_16_MASK_SHIFT_2_4(p2) * 3 + INTERP_16_MASK_SHIFT_2_4(p3)) / 8); } static uint16 hq2x_interp_16_53(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*5 + INTERP_16_MASK_1_3(p2)*3) / 8) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*5 + INTERP_16_MASK_SHIFT_2_4(p2)*3) / 8); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 5 + INTERP_16_MASK_1_3(p2) * 3) / 8) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 5 + INTERP_16_MASK_SHIFT_2_4(p2) * 3) / 8); } static uint16 hq2x_interp_16_151(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*15 + INTERP_16_MASK_1_3(p2)) / 16) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*15 + INTERP_16_MASK_SHIFT_2_4(p2)) / 16); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 15 + INTERP_16_MASK_1_3(p2)) / 16) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 15 + INTERP_16_MASK_SHIFT_2_4(p2)) / 16); } static uint16 hq2x_interp_16_97(uint16 p1, uint16 p2) { - return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1)*9 + INTERP_16_MASK_1_3(p2)*7) / 16) - | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1)*9 + INTERP_16_MASK_SHIFT_2_4(p2)*7) / 16); + return INTERP_16_MASK_1_3((INTERP_16_MASK_1_3(p1) * 9 + INTERP_16_MASK_1_3(p2) * 7) / 16) + | INTERP_16_MASK_SHIFTBACK_2_4((INTERP_16_MASK_SHIFT_2_4(p1) * 9 + INTERP_16_MASK_SHIFT_2_4(p2) * 7) / 16); } #endif /* !_16BPP_HACK */ @@ -127,80 +116,80 @@ static uint16 hq2x_interp_16_97(uint16 p1, uint16 p2) static uint32 hq2x_interp_32_521(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*2 + INTERP_32_MASK_1_3(p3)*1) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*2 + INTERP_32_MASK_SHIFT_2_4(p3)*1) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 5 + INTERP_32_MASK_1_3(p2) * 2 + INTERP_32_MASK_1_3(p3) * 1) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 5 + INTERP_32_MASK_SHIFT_2_4(p2) * 2 + INTERP_32_MASK_SHIFT_2_4(p3) * 1) / 8); } static uint32 hq2x_interp_32_332(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)*2) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 3 + INTERP_32_MASK_1_3(p2) * 3 + INTERP_32_MASK_1_3(p3) * 2) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 3 + INTERP_32_MASK_SHIFT_2_4(p2) * 3 + INTERP_32_MASK_SHIFT_2_4(p3) * 2) / 8); } static uint32 hq2x_interp_32_211(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*2 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 4) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*2 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 4); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 2 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 4) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 2 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 4); } static uint32 hq2x_interp_32_611(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*6 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*6 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 6 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 6 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 8); } static uint32 hq2x_interp_32_71(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*7 + INTERP_32_MASK_1_3(p2)) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*7 + INTERP_32_MASK_SHIFT_2_4(p2)) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 7 + INTERP_32_MASK_1_3(p2)) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 7 + INTERP_32_MASK_SHIFT_2_4(p2)) / 8); } static uint32 hq2x_interp_32_772(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3(((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2))*7 + INTERP_32_MASK_1_3(p3)*2) / 16) - | INTERP_32_MASK_SHIFTBACK_2_4(((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2))*7 + INTERP_32_MASK_SHIFT_2_4(p3)*2) / 16); + return INTERP_32_MASK_1_3(((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2)) * 7 + INTERP_32_MASK_1_3(p3) * 2) / 16) + | INTERP_32_MASK_SHIFTBACK_2_4(((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2)) * 7 + INTERP_32_MASK_SHIFT_2_4(p3) * 2) / 16); } static uint32 hq2x_interp_32_11(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2)) / 2) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2)) / 2); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) + INTERP_32_MASK_1_3(p2)) / 2) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) + INTERP_32_MASK_SHIFT_2_4(p2)) / 2); } static uint32 hq2x_interp_32_31(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*3 + INTERP_32_MASK_1_3(p2)) / 4) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*3 + INTERP_32_MASK_SHIFT_2_4(p2)) / 4); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 3 + INTERP_32_MASK_1_3(p2)) / 4) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 3 + INTERP_32_MASK_SHIFT_2_4(p2)) / 4); } static uint32 hq2x_interp_32_1411(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*14 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 16) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*14 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 16); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 14 + INTERP_32_MASK_1_3(p2) + INTERP_32_MASK_1_3(p3)) / 16) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 14 + INTERP_32_MASK_SHIFT_2_4(p2) + INTERP_32_MASK_SHIFT_2_4(p3)) / 16); } static uint32 hq2x_interp_32_431(uint32 p1, uint32 p2, uint32 p3) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*4 + INTERP_32_MASK_1_3(p2)*3 + INTERP_32_MASK_1_3(p3)) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*4 + INTERP_32_MASK_SHIFT_2_4(p2)*3 + INTERP_32_MASK_SHIFT_2_4(p3)) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 4 + INTERP_32_MASK_1_3(p2) * 3 + INTERP_32_MASK_1_3(p3)) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 4 + INTERP_32_MASK_SHIFT_2_4(p2) * 3 + INTERP_32_MASK_SHIFT_2_4(p3)) / 8); } static uint32 hq2x_interp_32_53(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*5 + INTERP_32_MASK_1_3(p2)*3) / 8) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*5 + INTERP_32_MASK_SHIFT_2_4(p2)*3) / 8); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 5 + INTERP_32_MASK_1_3(p2) * 3) / 8) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 5 + INTERP_32_MASK_SHIFT_2_4(p2) * 3) / 8); } static uint32 hq2x_interp_32_151(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*15 + INTERP_32_MASK_1_3(p2)) / 16) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*15 + INTERP_32_MASK_SHIFT_2_4(p2)) / 16); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 15 + INTERP_32_MASK_1_3(p2)) / 16) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 15 + INTERP_32_MASK_SHIFT_2_4(p2)) / 16); } static uint32 hq2x_interp_32_97(uint32 p1, uint32 p2) { - return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1)*9 + INTERP_32_MASK_1_3(p2)*7) / 16) - | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1)*9 + INTERP_32_MASK_SHIFT_2_4(p2)*7) / 16); + return INTERP_32_MASK_1_3((INTERP_32_MASK_1_3(p1) * 9 + INTERP_32_MASK_1_3(p2) * 7) / 16) + | INTERP_32_MASK_SHIFTBACK_2_4((INTERP_32_MASK_SHIFT_2_4(p1) * 9 + INTERP_32_MASK_SHIFT_2_4(p2) * 7) / 16); } /***************************************************************************/ @@ -213,59 +202,59 @@ static uint32 hq2x_interp_32_97(uint32 p1, uint32 p2) #if !_16BPP_HACK static int hq2x_interp_16_diff(uint16 p1, uint16 p2) { - int r, g, b; - int y, u, v; + int r, g, b; + int y, u, v; + + if (p1 == p2) + return 0; + + b = (int)((p1 & 0x000F) - (p2 & 0x000F)); + g = (int)((p1 & 0x00F0) - (p2 & 0x00F0)) >> 4; + r = (int)((p1 & 0x0F00) - (p2 & 0x0F00)) >> 8; + + y = r + g + b; + u = r - b; + v = -r + 2 * g - b; + + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; + + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; + + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; - if (p1 == p2) return 0; - - b = (int)((p1 & 0x000F) - (p2 & 0x000F)); - g = (int)((p1 & 0x00F0) - (p2 & 0x00F0)) >> 4; - r = (int)((p1 & 0x0F00) - (p2 & 0x0F00)) >> 8; - - y = r + g + b; - u = r - b; - v = -r + 2*g - b; - - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; - - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; - - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; - - return 0; } #endif /* !_16BPP_HACK */ static int hq2x_interp_32_diff(uint32 p1, uint32 p2) { - int r, g, b; - int y, u, v; + int r, g, b; + int y, u, v; + + if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) + return 0; + + b = (int)((p1 & 0xFF) - (p2 & 0xFF)); + g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; + r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; + + y = r + g + b; + u = r - b; + v = -r + 2 * g - b; + + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; + + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; + + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; - if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) return 0; - - b = (int)((p1 & 0xFF) - (p2 & 0xFF)); - g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; - r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; - - y = r + g + b; - u = r - b; - v = -r + 2*g - b; - - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; - - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; - - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; - - return 0; } /*static void interp_set(unsigned bits_per_pixel) @@ -276,55 +265,57 @@ static int hq2x_interp_32_diff(uint32 p1, uint32 p2) #if !_16BPP_HACK static void hq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const uint16* src1, const uint16* src2, unsigned count) { - unsigned i; + unsigned i; - for(i=0;i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i> 3; - r = (int)((c[j] & 0xF800)) >> 8; - } else { - b = (int)((c[j] & 0x1F)) << 3; - g = (int)((c[j] & 0x3E0)) >> 2; - r = (int)((c[j] & 0x7C00)) >> 7; - } - const int bright = r+r+r + g+g+g + b+b; - if(bright > maxBright) maxBright = bright; - if(bright < minBright) minBright = bright; + // hq2xS dynamic edge detection: + // simply comparing the center color against its surroundings will give bad results in many cases, + // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block + int brightArray[9]; + int maxBright = 0, minBright = 999999; + for (int j = 0; j < 9; j++) { + int r, g, b; + if (interp_bits_per_pixel == 16) { + b = (int)((c[j] & 0x1F)) << 3; + g = (int)((c[j] & 0x7E0)) >> 3; + r = (int)((c[j] & 0xF800)) >> 8; + } + else { + b = (int)((c[j] & 0x1F)) << 3; + g = (int)((c[j] & 0x3E0)) >> 2; + r = (int)((c[j] & 0x7C00)) >> 7; + } + const int bright = r + r + r + g + g + g + b + b; + if (bright > maxBright) maxBright = bright; + if (bright < minBright) minBright = bright; - brightArray[j] = bright; - } - int diffBright = ((maxBright - minBright) * 7) >> 4; - if(diffBright > 7) { + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if (diffBright > 7) { #define ABS(x) ((x) < 0 ? -(x) : (x)) - const int centerBright = brightArray[4]; - if(ABS(brightArray[0] - centerBright) > diffBright) - mask |= 1 << 0; - if(ABS(brightArray[1] - centerBright) > diffBright) - mask |= 1 << 1; - if(ABS(brightArray[2] - centerBright) > diffBright) - mask |= 1 << 2; - if(ABS(brightArray[3] - centerBright) > diffBright) - mask |= 1 << 3; - if(ABS(brightArray[5] - centerBright) > diffBright) - mask |= 1 << 4; - if(ABS(brightArray[6] - centerBright) > diffBright) - mask |= 1 << 5; - if(ABS(brightArray[7] - centerBright) > diffBright) - mask |= 1 << 6; - if(ABS(brightArray[8] - centerBright) > diffBright) - mask |= 1 << 7; - } + const int centerBright = brightArray[4]; + if (ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if (ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if (ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if (ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if (ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if (ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if (ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if (ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } #define P0 dst0[0] #define P1 dst0[1] @@ -487,9 +481,9 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u #define I1411(p0,p1,p2) hq2x_interp_16_1411(c[p0], c[p1], c[p2]) #define I151(p0,p1) hq2x_interp_16_151(c[p0], c[p1]) - switch (mask) { + switch (mask) { #include "TextureFilters_hq2x.h" - } + } #undef P0 #undef P1 @@ -514,66 +508,68 @@ static void hq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u #undef I1411 #undef I151 - src0 += 1; - src1 += 1; - src2 += 1; - dst0 += 2; - dst1 += 2; - } + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } } #endif /* !_16BPP_HACK */ static void hq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const uint32* src1, const uint32* src2, unsigned count) { - unsigned i; + unsigned i; - for(i=0;i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = src0[0]; - c[3] = src1[0]; - c[6] = src2[0]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = src0[0]; + c[3] = src1[0]; + c[6] = src2[0]; + } - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = src0[0]; - c[3] = src1[0]; - c[6] = src2[0]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = src0[0]; + c[3] = src1[0]; + c[6] = src2[0]; + } - if (i> 8; - const int r = (int)((c[j] & 0xF80000)) >> 16; - const int bright = r+r+r + g+g+g + b+b; - if(bright > maxBright) maxBright = bright; - if(bright < minBright) minBright = bright; + if (i < count - 1) { + c[2] = src0[1]; + c[5] = src1[1]; + c[8] = src2[1]; + } + else { + c[2] = src0[0]; + c[5] = src1[0]; + c[8] = src2[0]; + } - brightArray[j] = bright; - } - int diffBright = ((maxBright - minBright) * 7) >> 4; - if(diffBright > 7) { + mask = 0; + // hq2xS dynamic edge detection: + // simply comparing the center color against its surroundings will give bad results in many cases, + // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block + int brightArray[9]; + int maxBright = 0, minBright = 999999; + for (int j = 0; j < 9; j++) { + const int b = (int)((c[j] & 0xF8)); + const int g = (int)((c[j] & 0xF800)) >> 8; + const int r = (int)((c[j] & 0xF80000)) >> 16; + const int bright = r + r + r + g + g + g + b + b; + if (bright > maxBright) maxBright = bright; + if (bright < minBright) minBright = bright; + + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if (diffBright > 7) { #define ABS(x) ((x) < 0 ? -(x) : (x)) - const int centerBright = brightArray[4]; - if(ABS(brightArray[0] - centerBright) > diffBright) - mask |= 1 << 0; - if(ABS(brightArray[1] - centerBright) > diffBright) - mask |= 1 << 1; - if(ABS(brightArray[2] - centerBright) > diffBright) - mask |= 1 << 2; - if(ABS(brightArray[3] - centerBright) > diffBright) - mask |= 1 << 3; - if(ABS(brightArray[5] - centerBright) > diffBright) - mask |= 1 << 4; - if(ABS(brightArray[6] - centerBright) > diffBright) - mask |= 1 << 5; - if(ABS(brightArray[7] - centerBright) > diffBright) - mask |= 1 << 6; - if(ABS(brightArray[8] - centerBright) > diffBright) - mask |= 1 << 7; - } + const int centerBright = brightArray[4]; + if (ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if (ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if (ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if (ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if (ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if (ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if (ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if (ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } #define P0 dst0[0] #define P1 dst0[1] #define P2 dst1[0] @@ -727,9 +725,9 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u #define I1411(p0,p1,p2) hq2x_interp_32_1411(c[p0], c[p1], c[p2]) #define I151(p0,p1) hq2x_interp_32_151(c[p0], c[p1]) - switch (mask) { + switch (mask) { #include "TextureFilters_hq2x.h" - } + } #undef P0 #undef P1 @@ -754,12 +752,12 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u #undef I1411 #undef I151 - src0 += 1; - src1 += 1; - src2 += 1; - dst0 += 2; - dst1 += 2; - } + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } } /***************************************************************************/ @@ -772,55 +770,57 @@ static void hq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u #if !_16BPP_HACK static void lq2x_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const uint16* src1, const uint16* src2, unsigned count) { - unsigned i; + unsigned i; - for(i=0;i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i> 8; - const int r = (int)((c[j] & 0xF80000)) >> 16; - const int bright = r+r+r + g+g+g + b+b; - if(bright > maxBright) maxBright = bright; - if(bright < minBright) minBright = bright; + // hq2xS dynamic edge detection: + // simply comparing the center color against its surroundings will give bad results in many cases, + // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block + int brightArray[9]; + int maxBright = 0, minBright = 999999; + for (int j = 0; j < 9; j++) { + const int b = (int)((c[j] & 0xF8)); + const int g = (int)((c[j] & 0xF800)) >> 8; + const int r = (int)((c[j] & 0xF80000)) >> 16; + const int bright = r + r + r + g + g + g + b + b; + if (bright > maxBright) maxBright = bright; + if (bright < minBright) minBright = bright; - brightArray[j] = bright; - } - int diffBright = ((maxBright - minBright) * 7) >> 4; - if(diffBright > 7) { + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if (diffBright > 7) { #define ABS(x) ((x) < 0 ? -(x) : (x)) - const int centerBright = brightArray[4]; - if(ABS(brightArray[0] - centerBright) > diffBright) - mask |= 1 << 0; - if(ABS(brightArray[1] - centerBright) > diffBright) - mask |= 1 << 1; - if(ABS(brightArray[2] - centerBright) > diffBright) - mask |= 1 << 2; - if(ABS(brightArray[3] - centerBright) > diffBright) - mask |= 1 << 3; - if(ABS(brightArray[5] - centerBright) > diffBright) - mask |= 1 << 4; - if(ABS(brightArray[6] - centerBright) > diffBright) - mask |= 1 << 5; - if(ABS(brightArray[7] - centerBright) > diffBright) - mask |= 1 << 6; - if(ABS(brightArray[8] - centerBright) > diffBright) - mask |= 1 << 7; - } + const int centerBright = brightArray[4]; + if (ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if (ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if (ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if (ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if (ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if (ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if (ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if (ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } #define P0 dst0[0] #define P1 dst0[1] @@ -974,9 +976,9 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u #define I1411(p0,p1,p2) hq2x_interp_16_1411(c[p0], c[p1], c[p2]) #define I151(p0,p1) hq2x_interp_16_151(c[p0], c[p1]) - switch (mask) { + switch (mask) { #include "TextureFilters_lq2x.h" - } + } #undef P0 #undef P1 @@ -1001,66 +1003,68 @@ static void lq2xS_16_def(uint16* dst0, uint16* dst1, const uint16* src0, const u #undef I1411 #undef I151 - src0 += 1; - src1 += 1; - src2 += 1; - dst0 += 2; - dst1 += 2; - } + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } } #endif /* !_16BPP_HACK */ static void lq2x_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const uint32* src1, const uint32* src2, unsigned count) { - unsigned i; + unsigned i; - for(i=0;i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i0) { - c[0] = src0[-1]; - c[3] = src1[-1]; - c[6] = src2[-1]; - } else { - c[0] = c[1]; - c[3] = c[4]; - c[6] = c[7]; - } + if (i > 0) { + c[0] = src0[-1]; + c[3] = src1[-1]; + c[6] = src2[-1]; + } + else { + c[0] = c[1]; + c[3] = c[4]; + c[6] = c[7]; + } - if (i> 8; - const int r = (int)((c[j] & 0xF80000)) >> 16; - const int bright = r+r+r + g+g+g + b+b; - if(bright > maxBright) maxBright = bright; - if(bright < minBright) minBright = bright; + // hq2xS dynamic edge detection: + // simply comparing the center color against its surroundings will give bad results in many cases, + // so, instead, compare the center color relative to the max difference in brightness of this 3x3 block + int brightArray[9]; + int maxBright = 0, minBright = 999999; + for (int j = 0; j < 9; j++) { + const int b = (int)((c[j] & 0xF8)); + const int g = (int)((c[j] & 0xF800)) >> 8; + const int r = (int)((c[j] & 0xF80000)) >> 16; + const int bright = r + r + r + g + g + g + b + b; + if (bright > maxBright) maxBright = bright; + if (bright < minBright) minBright = bright; - brightArray[j] = bright; - } - int diffBright = ((maxBright - minBright) * 7) >> 4; - if(diffBright > 7) { + brightArray[j] = bright; + } + int diffBright = ((maxBright - minBright) * 7) >> 4; + if (diffBright > 7) { #define ABS(x) ((x) < 0 ? -(x) : (x)) - const int centerBright = brightArray[4]; - if(ABS(brightArray[0] - centerBright) > diffBright) - mask |= 1 << 0; - if(ABS(brightArray[1] - centerBright) > diffBright) - mask |= 1 << 1; - if(ABS(brightArray[2] - centerBright) > diffBright) - mask |= 1 << 2; - if(ABS(brightArray[3] - centerBright) > diffBright) - mask |= 1 << 3; - if(ABS(brightArray[5] - centerBright) > diffBright) - mask |= 1 << 4; - if(ABS(brightArray[6] - centerBright) > diffBright) - mask |= 1 << 5; - if(ABS(brightArray[7] - centerBright) > diffBright) - mask |= 1 << 6; - if(ABS(brightArray[8] - centerBright) > diffBright) - mask |= 1 << 7; - } + const int centerBright = brightArray[4]; + if (ABS(brightArray[0] - centerBright) > diffBright) + mask |= 1 << 0; + if (ABS(brightArray[1] - centerBright) > diffBright) + mask |= 1 << 1; + if (ABS(brightArray[2] - centerBright) > diffBright) + mask |= 1 << 2; + if (ABS(brightArray[3] - centerBright) > diffBright) + mask |= 1 << 3; + if (ABS(brightArray[5] - centerBright) > diffBright) + mask |= 1 << 4; + if (ABS(brightArray[6] - centerBright) > diffBright) + mask |= 1 << 5; + if (ABS(brightArray[7] - centerBright) > diffBright) + mask |= 1 << 6; + if (ABS(brightArray[8] - centerBright) > diffBright) + mask |= 1 << 7; + } #define P0 dst0[0] #define P1 dst0[1] @@ -1214,9 +1220,9 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u #define I1411(p0,p1,p2) hq2x_interp_32_1411(c[p0], c[p1], c[p2]) #define I151(p0,p1) hq2x_interp_32_151(c[p0], c[p1]) - switch (mask) { + switch (mask) { #include "TextureFilters_lq2x.h" - } + } #undef P0 #undef P1 @@ -1241,259 +1247,258 @@ static void lq2xS_32_def(uint32* dst0, uint32* dst1, const uint32* src0, const u #undef I1411 #undef I151 - src0 += 1; - src1 += 1; - src2 += 1; - dst0 += 2; - dst1 += 2; - } + src0 += 1; + src1 += 1; + src2 += 1; + dst0 += 2; + dst1 += 2; + } } #if !_16BPP_HACK void hq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint16 *dst0 = (uint16 *)dstPtr; - uint16 *dst1 = dst0 + (dstPitch >> 1); + uint16 *dst0 = (uint16 *)dstPtr; + uint16 *dst1 = dst0 + (dstPitch >> 1); - uint16 *src0 = (uint16 *)srcPtr; - uint16 *src1 = src0 + (srcPitch >> 1); - uint16 *src2 = src1 + (srcPitch >> 1); + uint16 *src0 = (uint16 *)srcPtr; + uint16 *src1 = src0 + (srcPitch >> 1); + uint16 *src2 = src1 + (srcPitch >> 1); - int count; + int count; - hq2x_16_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + hq2x_16_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } dst0 += dstPitch; dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src1, width); + hq2x_16_def(dst0, dst1, src0, src1, src1, width); } - void hq2xS_16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, - u8 *dstPtr, u32 dstPitch, int width, int height) + u8 *dstPtr, u32 dstPitch, int width, int height) { - u16 *dst0 = (u16 *)dstPtr; - u16 *dst1 = dst0 + (dstPitch >> 1); - - u16 *src0 = (u16 *)srcPtr; - u16 *src1 = src0 + (srcPitch >> 1); - u16 *src2 = src1 + (srcPitch >> 1); - - hq2xS_16_def(dst0, dst1, src0, src0, src1, width); - - int count = height; - - count -= 2; - while(count) { + u16 *dst0 = (u16 *)dstPtr; + u16 *dst1 = dst0 + (dstPitch >> 1); + + u16 *src0 = (u16 *)srcPtr; + u16 *src1 = src0 + (srcPitch >> 1); + u16 *src2 = src1 + (srcPitch >> 1); + + hq2xS_16_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while (count) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2xS_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } dst0 += dstPitch; dst1 += dstPitch; - hq2xS_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - hq2xS_16_def(dst0, dst1, src0, src1, src1, width); + hq2xS_16_def(dst0, dst1, src0, src1, src1, width); } #endif /* !_16BPP_HACK */ void hq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint32 *dst0 = (uint32 *)dstPtr; - uint32 *dst1 = dst0 + (dstPitch >> 2); + uint32 *dst0 = (uint32 *)dstPtr; + uint32 *dst1 = dst0 + (dstPitch >> 2); - uint32 *src0 = (uint32 *)srcPtr; - uint32 *src1 = src0 + (srcPitch >> 2); - uint32 *src2 = src1 + (srcPitch >> 2); + uint32 *src0 = (uint32 *)srcPtr; + uint32 *src1 = src0 + (srcPitch >> 2); + uint32 *src2 = src1 + (srcPitch >> 2); - int count; + int count; - hq2x_32_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + hq2x_32_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } dst0 += dstPitch >> 1; dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src1, width); + hq2x_32_def(dst0, dst1, src0, src1, src1, width); } void hq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint32 *dst0 = (uint32 *)dstPtr; - uint32 *dst1 = dst0 + (dstPitch >> 2); + uint32 *dst0 = (uint32 *)dstPtr; + uint32 *dst1 = dst0 + (dstPitch >> 2); - uint32 *src0 = (uint32 *)srcPtr; - uint32 *src1 = src0 + (srcPitch >> 2); - uint32 *src2 = src1 + (srcPitch >> 2); - hq2xS_32_def(dst0, dst1, src0, src0, src1, width); - - int count = height; - - count -= 2; - while(count) { + uint32 *src0 = (uint32 *)srcPtr; + uint32 *src1 = src0 + (srcPitch >> 2); + uint32 *src2 = src1 + (srcPitch >> 2); + hq2xS_32_def(dst0, dst1, src0, src0, src1, width); + + int count = height; + + count -= 2; + while (count) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2xS_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } dst0 += dstPitch >> 1; dst1 += dstPitch >> 1; - hq2xS_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - hq2xS_32_def(dst0, dst1, src0, src1, src1, width); + hq2xS_32_def(dst0, dst1, src0, src1, src1, width); } #if !_16BPP_HACK void lq2x_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint16 *dst0 = (uint16 *)dstPtr; - uint16 *dst1 = dst0 + (dstPitch >> 1); + uint16 *dst0 = (uint16 *)dstPtr; + uint16 *dst1 = dst0 + (dstPitch >> 1); - uint16 *src0 = (uint16 *)srcPtr; - uint16 *src1 = src0 + (srcPitch >> 1); - uint16 *src2 = src1 + (srcPitch >> 1); + uint16 *src0 = (uint16 *)srcPtr; + uint16 *src1 = src0 + (srcPitch >> 1); + uint16 *src2 = src1 + (srcPitch >> 1); - int count; + int count; - lq2x_16_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + lq2x_16_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } dst0 += dstPitch; dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - lq2x_16_def(dst0, dst1, src0, src1, src1, width); + lq2x_16_def(dst0, dst1, src0, src1, src1, width); } void lq2xS_16(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint16 *dst0 = (uint16 *)dstPtr; - uint16 *dst1 = dst0 + (dstPitch >> 1); + uint16 *dst0 = (uint16 *)dstPtr; + uint16 *dst1 = dst0 + (dstPitch >> 1); - uint16 *src0 = (uint16 *)srcPtr; - uint16 *src1 = src0 + (srcPitch >> 1); - uint16 *src2 = src1 + (srcPitch >> 1); + uint16 *src0 = (uint16 *)srcPtr; + uint16 *src1 = src0 + (srcPitch >> 1); + uint16 *src2 = src1 + (srcPitch >> 1); - int count; + int count; - lq2xS_16_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + lq2xS_16_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch; + dst1 += dstPitch; + hq2x_16_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 1; + --count; + } dst0 += dstPitch; dst1 += dstPitch; - hq2x_16_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 1; - --count; - } - dst0 += dstPitch; - dst1 += dstPitch; - lq2xS_16_def(dst0, dst1, src0, src1, src1, width); + lq2xS_16_def(dst0, dst1, src0, src1, src1, width); } #endif /* !_16BPP_HACK */ void lq2x_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint32 *dst0 = (uint32 *)dstPtr; - uint32 *dst1 = dst0 + (dstPitch >> 2); + uint32 *dst0 = (uint32 *)dstPtr; + uint32 *dst1 = dst0 + (dstPitch >> 2); - uint32 *src0 = (uint32 *)srcPtr; - uint32 *src1 = src0 + (srcPitch >> 2); - uint32 *src2 = src1 + (srcPitch >> 2); + uint32 *src0 = (uint32 *)srcPtr; + uint32 *src1 = src0 + (srcPitch >> 2); + uint32 *src2 = src1 + (srcPitch >> 2); - int count; + int count; - lq2x_32_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + lq2x_32_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } dst0 += dstPitch >> 1; dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - lq2x_32_def(dst0, dst1, src0, src1, src1, width); + lq2x_32_def(dst0, dst1, src0, src1, src1, width); } void lq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, int width, int height) { - uint32 *dst0 = (uint32 *)dstPtr; - uint32 *dst1 = dst0 + (dstPitch >> 2); + uint32 *dst0 = (uint32 *)dstPtr; + uint32 *dst1 = dst0 + (dstPitch >> 2); - uint32 *src0 = (uint32 *)srcPtr; - uint32 *src1 = src0 + (srcPitch >> 2); - uint32 *src2 = src1 + (srcPitch >> 2); + uint32 *src0 = (uint32 *)srcPtr; + uint32 *src1 = src0 + (srcPitch >> 2); + uint32 *src2 = src1 + (srcPitch >> 2); - int count; + int count; - lq2xS_32_def(dst0, dst1, src0, src0, src1, width); - if( height == 1 ) return; + lq2xS_32_def(dst0, dst1, src0, src0, src1, width); + if (height == 1) return; - count = height; + count = height; - count -= 2; - while(count>0) { + count -= 2; + while (count > 0) { + dst0 += dstPitch >> 1; + dst1 += dstPitch >> 1; + hq2x_32_def(dst0, dst1, src0, src1, src2, width); + src0 = src1; + src1 = src2; + src2 += srcPitch >> 2; + --count; + } dst0 += dstPitch >> 1; dst1 += dstPitch >> 1; - hq2x_32_def(dst0, dst1, src0, src1, src2, width); - src0 = src1; - src1 = src2; - src2 += srcPitch >> 2; - --count; - } - dst0 += dstPitch >> 1; - dst1 += dstPitch >> 1; - lq2xS_32_def(dst0, dst1, src0, src1, src1, width); + lq2xS_32_def(dst0, dst1, src0, src1, src1, width); } /************************************************************************/ @@ -1506,5 +1511,4 @@ void lq2xS_32(uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch, in /************************************************************************/ /* scale3x filters */ -/************************************************************************/ - +/************************************************************************/ \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h index 7946323b8..f9fda3639 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq2x.h @@ -1,1847 +1,2002 @@ -/* -Copyright (C) 2003 Rice1964 +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 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-1307, USA. - -*/ - -/* Copyright (C) 2007 Hiroshi Morii - * Modified for the Texture Filtering library - */ - -case 0 : -case 1 : -case 4 : -case 5 : -case 32 : -case 33 : -case 36 : -case 37 : -case 128 : -case 129 : -case 132 : -case 133 : -case 160 : -case 161 : -case 164 : -case 165 : +case 0: +case 1: +case 4: +case 5: +case 32: +case 33: +case 36: +case 37: +case 128: +case 129: +case 132: +case 133: +case 160: +case 161: +case 164: +case 165: { - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 2 : -case 34 : -case 130 : -case 162 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 3 : -case 35 : -case 131 : -case 163 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 6 : -case 38 : -case 134 : -case 166 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 7 : -case 39 : -case 135 : -case 167 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 8 : -case 12 : -case 136 : -case 140 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 9 : -case 13 : -case 137 : -case 141 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 10 : -case 138 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { P0 = I211(4, 1, 3); - } -} break; -case 11 : -case 139 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 15 : -case 143 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = IC(4); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 16 : -case 17 : -case 48 : -case 49 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 18 : -case 50 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { P1 = I211(4, 1, 5); - } + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); } break; -case 19 : -case 51 : +case 2: +case 34: +case 130: +case 162: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 3: +case 35: +case 131: +case 163: { - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (HQ2X_MUR) { P0 = I31(4, 3); P1 = I31(4, 2); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 20 : -case 21 : -case 52 : -case 53 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 22 : -case 54 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 23 : -case 55 : -{ - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 24 : -case 66 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 25 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 26 : -case 31 : -case 95 : -{ - P2 = I31(4, 6); - P3 = I31(4, 8); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 27 : -case 75 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 28 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 29 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 30 : -case 86 : -{ - P0 = I31(4, 0); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 40 : -case 44 : -case 168 : -case 172 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 41 : -case 45 : -case 169 : -case 173 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 42 : -case 170 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 43 : -case 171 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 46 : -case 174 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 56 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 57 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 58 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 59 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 60 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 61 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 62 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 63 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 64 : -case 65 : -case 68 : -case 69 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 67 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 70 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 71 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 72 : -case 76 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { P2 = I211(4, 3, 7); - } -} break; -case 73 : -case 77 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P0 = I31(4, 1); - P2 = I31(4, 6); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 74 : -case 107 : -case 123 : -{ - P1 = I31(4, 2); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 78 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 79 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 81 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { P3 = I211(4, 5, 7); - } } break; -case 82 : -case 214 : -case 222 : +case 6: +case 38: +case 134: +case 166: { - P0 = I31(4, 0); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 83 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 84 : -case 85 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P1 = I31(4, 1); - P3 = I31(4, 8); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 87 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 89 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 90 : -{ - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUL) { P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 91 : -{ - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 92 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 93 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 94 : -{ - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 96 : -case 97 : -case 100 : -case 101 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 98 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 99 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 102 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 103 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 104 : -case 108 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 105 : -case 109 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 106 : -case 120 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 110 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 111 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 113 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (HQ2X_MDR) { - P2 = I31(4, 3); - P3 = I31(4, 8); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 114 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 115 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 116 : -case 117 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 118 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 119 : -{ - P2 = I31(4, 3); - P3 = I31(4, 8); - if (HQ2X_MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 121 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 122 : -{ - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 124 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 125 : -{ - P1 = I31(4, 1); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 126 : -{ - P0 = I31(4, 0); - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 127 : -{ - P3 = I31(4, 8); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 144 : -case 145 : -case 176 : -case 177 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 146 : -case 178 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (HQ2X_MUR) { - P1 = I31(4, 2); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 147 : -case 179 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 148 : -case 149 : -case 180 : -case 181 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 150 : -case 182 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (HQ2X_MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 151 : -case 183 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 152 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 153 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 154 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 155 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 156 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 157 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 158 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 159 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 184 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 185 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 186 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 187 : -{ - P1 = I31(4, 2); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 188 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 189 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 190 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - if (HQ2X_MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 191 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 192 : -case 193 : -case 196 : -case 197 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 194 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 195 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 198 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 199 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 200 : -case 204 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (HQ2X_MDL) { - P2 = I31(4, 6); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 201 : -case 205 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } -} break; -case 202 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 203 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 206 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 207 : -{ - P2 = I31(4, 6); - P3 = I31(4, 5); - if (HQ2X_MUL) { - P0 = IC(4); P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 208 : -case 209 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { + P2 = I211(4, 3, 7); P3 = I211(4, 5, 7); - } } break; -case 210 : -case 216 : +case 7: +case 39: +case 135: +case 167: { - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I211(4, 3, 7); P3 = I211(4, 5, 7); - } } break; -case 211 : +case 8: +case 12: +case 136: +case 140: { - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 212 : -case 213 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 215 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 217 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 218 : -{ - if (HQ2X_MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUL) { P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 219 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 220 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (HQ2X_MDL) { + P1 = I211(4, 1, 5); P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { P3 = I211(4, 5, 7); - } } break; -case 221 : +case 9: +case 13: +case 137: +case 141: { - P0 = I31(4, 1); - P2 = I31(4, 6); - if (HQ2X_MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 223 : -{ - P2 = I31(4, 6); - if (HQ2X_MDR) { - P3 = IC(4); - } else { + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); P3 = I211(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } } break; -case 224 : -case 225 : -case 228 : -case 229 : +case 10: +case 138: { - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 226 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 227 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 230 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 231 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 232 : -case 236 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (HQ2X_MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 233 : -case 237 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } -} break; -case 234 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 235 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 238 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - if (HQ2X_MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 239 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 240 : -case 241 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (HQ2X_MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 242 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUR) { P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 243 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - if (HQ2X_MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 244 : -case 245 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 246 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 247 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 249 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { + P2 = I31(4, 6); P3 = I211(4, 5, 7); - } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I211(4, 1, 3); + } } break; -case 251 : +case 11: +case 139: { - P1 = I31(4, 2); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { + P1 = I31(4, 2); + P2 = I31(4, 6); P3 = I211(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 14: +case 142: +{ + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + P1 = I31(4, 5); + } + else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 15: +case 143: +{ + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } + else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 16: +case 17: +case 48: +case 49: +{ P0 = I211(4, 1, 3); - } -} break; -case 252 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (HQ2X_MDL) { - P2 = IC(4); - } else { + P1 = I31(4, 2); P2 = I211(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } + P3 = I31(4, 8); } break; -case 253 : +case 18: +case 50: { - P0 = I31(4, 1); - P1 = I31(4, 1); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 254 : -{ - P0 = I31(4, 0); - if (HQ2X_MDL) { - P2 = IC(4); - } else { + P0 = I31(4, 0); P2 = I211(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { + P3 = I31(4, 8); + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 19: +case 51: +{ + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P0 = I31(4, 3); + P1 = I31(4, 2); + } + else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 20: +case 21: +case 52: +case 53: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); +} break; +case 22: +case 54: +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 23: +case 55: +{ + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } + else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 24: +case 66: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 25: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 26: +case 31: +case 95: +{ + P2 = I31(4, 6); + P3 = I31(4, 8); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 27: +case 75: +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 28: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 29: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 30: +case 86: +{ + P0 = I31(4, 0); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 40: +case 44: +case 168: +case 172: +{ + P0 = I31(4, 0); P1 = I211(4, 1, 5); - } + P2 = I31(4, 7); + P3 = I211(4, 5, 7); } break; -case 255 : +case 41: +case 45: +case 169: +case 173: { - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); +} break; +case 42: +case 170: +{ + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + P2 = I31(4, 7); + } + else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 43: +case 171: +{ + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } + else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 46: +case 174: +{ + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } +} break; +case 47: +case 175: +{ + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 56: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 57: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 58: +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 59: +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 60: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 61: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 62: +{ + P0 = I31(4, 0); + P2 = I31(4, 7); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 63: +{ + P2 = I31(4, 7); + P3 = I31(4, 8); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 64: +case 65: +case 68: +case 69: +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 67: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 70: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 71: +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 72: +case 76: +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I211(4, 3, 7); + } +} break; +case 73: +case 77: +{ + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P0 = I31(4, 1); + P2 = I31(4, 6); + } + else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 74: +case 107: +case 123: +{ + P1 = I31(4, 2); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 78: +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } +} break; +case 79: +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 80: +case 81: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 82: +case 214: +case 222: +{ + P0 = I31(4, 0); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 83: +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 84: +case 85: +{ + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P1 = I31(4, 1); + P3 = I31(4, 8); + } + else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 87: +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 88: +case 248: +case 250: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 89: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } +} break; +case 90: +{ + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 91: +{ + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 92: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } +} break; +case 93: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } +} break; +case 94: +{ + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 96: +case 97: +case 100: +case 101: +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 98: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 99: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 102: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 103: +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 104: +case 108: +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } +} break; +case 105: +case 109: +{ + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } + else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 106: +case 120: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } +} break; +case 110: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } +} break; +case 111: +{ + P1 = I31(4, 5); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 112: +case 113: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (HQ2X_MDR) { + P2 = I31(4, 3); + P3 = I31(4, 8); + } + else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 114: +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 115: +{ + P0 = I31(4, 3); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 116: +case 117: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } +} break; +case 118: +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 119: +{ + P2 = I31(4, 3); + P3 = I31(4, 8); + if (HQ2X_MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } + else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 121: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } +} break; +case 122: +{ + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = I31(4, 8); + } + else { + P3 = I611(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 124: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } +} break; +case 125: +{ + P1 = I31(4, 1); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } + else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 126: +{ + P0 = I31(4, 0); + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 127: +{ + P3 = I31(4, 8); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 144: +case 145: +case 176: +case 177: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 146: +case 178: +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (HQ2X_MUR) { + P1 = I31(4, 2); + P3 = I31(4, 7); + } + else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 147: +case 179: +{ + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 148: +case 149: +case 180: +case 181: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 150: +case 182: +{ + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (HQ2X_MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } + else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 151: +case 183: +{ + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 152: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 153: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 154: +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 155: +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 156: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 157: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 158: +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 159: +{ + P2 = I31(4, 6); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 184: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 185: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 186: +{ + P2 = I31(4, 7); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 187: +{ + P1 = I31(4, 2); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } + else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 188: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 189: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 190: +{ + P0 = I31(4, 0); + P2 = I31(4, 7); + if (HQ2X_MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } + else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 191: +{ + P2 = I31(4, 7); + P3 = I31(4, 7); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 192: +case 193: +case 196: +case 197: +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 194: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 195: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 198: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 199: +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 200: +case 204: +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (HQ2X_MDL) { + P2 = I31(4, 6); + P3 = I31(4, 5); + } + else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 201: +case 205: +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } +} break; +case 202: +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } +} break; +case 203: +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 206: +{ + P1 = I31(4, 5); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } +} break; +case 207: +{ + P2 = I31(4, 6); + P3 = I31(4, 5); + if (HQ2X_MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } + else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 208: +case 209: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 210: +case 216: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 211: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 212: +case 213: +{ + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } + else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 215: +{ + P0 = I31(4, 3); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 217: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 218: +{ + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 219: +{ + P1 = I31(4, 2); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 220: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (HQ2X_MDL) { + P2 = I31(4, 6); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 221: +{ + P0 = I31(4, 1); + P2 = I31(4, 6); + if (HQ2X_MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } + else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 223: +{ + P2 = I31(4, 6); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 224: +case 225: +case 228: +case 229: +{ + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 226: +{ + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 227: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 230: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 231: +{ + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 232: +case 236: +{ + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (HQ2X_MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } + else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 233: +case 237: +{ + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } +} break; +case 234: +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = I31(4, 0); + } + else { + P0 = I611(4, 1, 3); + } +} break; +case 235: +{ + P1 = I31(4, 2); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 238: +{ + P0 = I31(4, 0); + P1 = I31(4, 5); + if (HQ2X_MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } + else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 239: +{ + P1 = I31(4, 5); + P3 = I31(4, 5); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 240: +case 241: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (HQ2X_MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } + else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 242: +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = I31(4, 2); + } + else { + P1 = I611(4, 1, 5); + } +} break; +case 243: +{ + P0 = I31(4, 3); + P1 = I31(4, 2); + if (HQ2X_MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } + else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 244: +case 245: +{ + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } +} break; +case 246: +{ + P0 = I31(4, 0); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 247: +{ + P0 = I31(4, 3); + P2 = I31(4, 3); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 249: +{ + P0 = I31(4, 1); + P1 = I31(4, 2); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } +} break; +case 251: +{ + P1 = I31(4, 2); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } +} break; +case 252: +{ + P0 = I31(4, 0); + P1 = I31(4, 1); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } +} break; +case 253: +{ + P0 = I31(4, 1); + P1 = I31(4, 1); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } +} break; +case 254: +{ + P0 = I31(4, 0); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 255: +{ + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } } break; diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp index 89c14ea21..8c34f8bb1 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.cpp @@ -1,28 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* Based on Maxim Stepin and Rice1964 hq4x code */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include #include "TextureFilters.h" @@ -51,92 +39,92 @@ static uint32 RGB444toYUV[4096]; static uint32 RGB555toYUV(uint32 val) { - uint32 r, g, b, Y, u, v; + uint32 r, g, b, Y, u, v; - r = (val & 0x7C00) >> 7; - g = (val & 0x03E0) >> 2; - b = (val & 0x001F) << 3; - r |= r >> 5; - g |= g >> 5; - b |= b >> 5; + r = (val & 0x7C00) >> 7; + g = (val & 0x03E0) >> 2; + b = (val & 0x001F) << 3; + r |= r >> 5; + g |= g >> 5; + b |= b >> 5; - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((2*g - r - b)>>3); + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((2 * g - r - b) >> 3); - return ((Y << 16) | (u << 8) | v); + return ((Y << 16) | (u << 8) | v); } static uint32 RGB565toYUV(uint32 val) { - uint32 r, g, b, Y, u, v; + uint32 r, g, b, Y, u, v; - r = (val & 0xF800) >> 8; - g = (val & 0x07E0) >> 3; - b = (val & 0x001F) << 3; - r |= r >> 5; - g |= g >> 6; - b |= b >> 5; + r = (val & 0xF800) >> 8; + g = (val & 0x07E0) >> 3; + b = (val & 0x001F) << 3; + r |= r >> 5; + g |= g >> 6; + b |= b >> 5; - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((2*g - r - b)>>3); + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((2 * g - r - b) >> 3); - return ((Y << 16) | (u << 8) | v); + return ((Y << 16) | (u << 8) | v); } #endif /* !_16BPP_HACK */ static uint32 RGB888toYUV(uint32 val) { #if 0 - uint32 Yuv; + uint32 Yuv; - __asm { - mov eax, dword ptr [val]; - mov ebx, eax; - mov ecx, eax; - and ebx, 0x000000ff; // b - and eax, 0x00ff0000; // r - and ecx, 0x0000ff00; // g - shl ebx, 14; - shr eax, 2; - shl ecx, 6; - mov edx, ebx; - add edx, eax; - add edx, ecx; - and edx, 0xffff0000; + __asm { + mov eax, dword ptr[val]; + mov ebx, eax; + mov ecx, eax; + and ebx, 0x000000ff; // b + and eax, 0x00ff0000; // r + and ecx, 0x0000ff00; // g + shl ebx, 14; + shr eax, 2; + shl ecx, 6; + mov edx, ebx; + add edx, eax; + add edx, ecx; + and edx, 0xffff0000; - sub eax, ebx; - add eax, 0x00800000; - shr eax, 8; - or edx, eax; - sub eax, 0x00800000; - and edx, 0xffffff00; + sub eax, ebx; + add eax, 0x00800000; + shr eax, 8; + or edx, eax; + sub eax, 0x00800000; + and edx, 0xffffff00; - add ecx, 0x00800000; - shr ecx, 5; - shr ebx, 7; - add eax, ebx; - sub ecx, eax; - shr ecx, 11; - or edx, ecx; + add ecx, 0x00800000; + shr ecx, 5; + shr ebx, 7; + add eax, ebx; + sub ecx, eax; + shr ecx, 11; + or edx, ecx; - mov dword ptr [Yuv], edx; - } + mov dword ptr[Yuv], edx; + } - return Yuv; + return Yuv; #else - uint32 r, g, b, Y, u, v; + uint32 r, g, b, Y, u, v; - r = (val & 0x00ff0000) >> 16; - g = (val & 0x0000ff00) >> 8; - b = val & 0x000000ff; + r = (val & 0x00ff0000) >> 16; + g = (val & 0x0000ff00) >> 8; + b = val & 0x000000ff; - Y = (r + g + b) >> 2; - u = (0x00000200 + r - b) >> 2; - v = (0x00000400 + (g << 1) - r - b) >> 3; + Y = (r + g + b) >> 2; + u = (0x00000200 + r - b) >> 2; + v = (0x00000400 + (g << 1) - r - b) >> 3; - return ((Y << 16) | (u << 8) | v); + return ((Y << 16) | (u << 8) | v); #endif } @@ -423,88 +411,90 @@ void hq4x_4444(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in #define BPP2 4 #define BPP3 6 - int i, j, k; - int prevline, nextline; - uint16 w[10]; - uint16 c[10]; + int i, j, k; + int prevline, nextline; + uint16 w[10]; + uint16 c[10]; - int pattern; - int flag; + int pattern; + int flag; - int YUV1, YUV2; + int YUV1, YUV2; - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ - for (j = 0; j < Yres; j++) { - if (j>0) prevline = -SrcPPL*2; else prevline = 0; - if (j 0) prevline = -SrcPPL * 2; else prevline = 0; + if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0; - for (i=0; i0) { - w[1] = *((uint16*)(pIn + prevline - 2)); - w[4] = *((uint16*)(pIn - 2)); - w[7] = *((uint16*)(pIn + nextline - 2)); - } else { - w[1] = w[2]; - w[4] = w[5]; - w[7] = w[8]; - } + if (i > 0) { + w[1] = *((uint16*)(pIn + prevline - 2)); + w[4] = *((uint16*)(pIn - 2)); + w[7] = *((uint16*)(pIn + nextline - 2)); + } + else { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } - if (i trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) - pattern |= flag; - } - flag <<= 1; - } + if (w[k] != w[5]) { + YUV2 = RGB444toYUV(w[k]); + if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) || + (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) || + (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV)) + pattern |= flag; + } + flag <<= 1; + } - for (k=1; k<=9; k++) - c[k] = w[k]; + for (k = 1; k <= 9; k++) + c[k] = w[k]; #include "TextureFilters_hq4x.h" - pIn+=2; - pOut+=8; + pIn += 2; + pOut += 8; + } + pIn += 2 * (SrcPPL - Xres); + pOut += 8 * (SrcPPL - Xres); + pOut += BpL; + pOut += BpL; + pOut += BpL; } - pIn += 2*(SrcPPL-Xres); - pOut+= 8*(SrcPPL-Xres); - pOut+=BpL; - pOut+=BpL; - pOut+=BpL; - } #undef BPP #undef BPP2 @@ -535,88 +525,90 @@ void hq4x_1555(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in #define BPP2 4 #define BPP3 6 - int i, j, k; - int prevline, nextline; - uint16 w[10]; - uint16 c[10]; + int i, j, k; + int prevline, nextline; + uint16 w[10]; + uint16 c[10]; - int pattern; - int flag; + int pattern; + int flag; - int YUV1, YUV2; + int YUV1, YUV2; - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ - for (j = 0; j < Yres; j++) { - if (j>0) prevline = -SrcPPL*2; else prevline = 0; - if (j 0) prevline = -SrcPPL * 2; else prevline = 0; + if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0; - for (i=0; i0) { - w[1] = *((uint16*)(pIn + prevline - 2)); - w[4] = *((uint16*)(pIn - 2)); - w[7] = *((uint16*)(pIn + nextline - 2)); - } else { - w[1] = w[2]; - w[4] = w[5]; - w[7] = w[8]; - } + if (i > 0) { + w[1] = *((uint16*)(pIn + prevline - 2)); + w[4] = *((uint16*)(pIn - 2)); + w[7] = *((uint16*)(pIn + nextline - 2)); + } + else { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } - if (i trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) - pattern |= flag; - } - flag <<= 1; - } + if (w[k] != w[5]) { + YUV2 = RGB555toYUV(w[k]); + if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) || + (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) || + (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV)) + pattern |= flag; + } + flag <<= 1; + } - for (k=1; k<=9; k++) - c[k] = w[k]; + for (k = 1; k <= 9; k++) + c[k] = w[k]; #include "TextureFilters_hq4x.h" - pIn+=2; - pOut+=8; + pIn += 2; + pOut += 8; + } + pIn += 2 * (SrcPPL - Xres); + pOut += 8 * (SrcPPL - Xres); + pOut += BpL; + pOut += BpL; + pOut += BpL; } - pIn += 2*(SrcPPL-Xres); - pOut+= 8*(SrcPPL-Xres); - pOut+=BpL; - pOut+=BpL; - pOut+=BpL; - } #undef BPP #undef BPP2 @@ -647,88 +639,90 @@ void hq4x_565(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, int #define BPP2 4 #define BPP3 6 - int i, j, k; - int prevline, nextline; - uint16 w[10]; - uint16 c[10]; + int i, j, k; + int prevline, nextline; + uint16 w[10]; + uint16 c[10]; - int pattern; - int flag; + int pattern; + int flag; - int YUV1, YUV2; + int YUV1, YUV2; - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ - for (j = 0; j < Yres; j++) { - if (j>0) prevline = -SrcPPL*2; else prevline = 0; - if (j 0) prevline = -SrcPPL * 2; else prevline = 0; + if (j < Yres - 1) nextline = SrcPPL * 2; else nextline = 0; - for (i=0; i0) { - w[1] = *((uint16*)(pIn + prevline - 2)); - w[4] = *((uint16*)(pIn - 2)); - w[7] = *((uint16*)(pIn + nextline - 2)); - } else { - w[1] = w[2]; - w[4] = w[5]; - w[7] = w[8]; - } + if (i > 0) { + w[1] = *((uint16*)(pIn + prevline - 2)); + w[4] = *((uint16*)(pIn - 2)); + w[7] = *((uint16*)(pIn + nextline - 2)); + } + else { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } - if (i trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) - pattern |= flag; - } - flag <<= 1; - } + if (w[k] != w[5]) { + YUV2 = RGB565toYUV(w[k]); + if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) || + (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) || + (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV)) + pattern |= flag; + } + flag <<= 1; + } - for (k=1; k<=9; k++) - c[k] = w[k]; + for (k = 1; k <= 9; k++) + c[k] = w[k]; #include "TextureFilters_hq4x.h" - pIn+=2; - pOut+=8; + pIn += 2; + pOut += 8; + } + pIn += 2 * (SrcPPL - Xres); + pOut += 8 * (SrcPPL - Xres); + pOut += BpL; + pOut += BpL; + pOut += BpL; } - pIn += 2*(SrcPPL-Xres); - pOut+= 8*(SrcPPL-Xres); - pOut+=BpL; - pOut+=BpL; - pOut+=BpL; - } #undef BPP #undef BPP2 @@ -760,89 +754,91 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in #define BPP2 8 #define BPP3 12 - int i, j, k; - int prevline, nextline; - uint32 w[10]; - uint32 c[10]; + int i, j, k; + int prevline, nextline; + uint32 w[10]; + uint32 c[10]; - int pattern; - int flag; + int pattern; + int flag; - int YUV1, YUV2; + int YUV1, YUV2; - // +----+----+----+ - // | | | | - // | w1 | w2 | w3 | - // +----+----+----+ - // | | | | - // | w4 | w5 | w6 | - // +----+----+----+ - // | | | | - // | w7 | w8 | w9 | - // +----+----+----+ + // +----+----+----+ + // | | | | + // | w1 | w2 | w3 | + // +----+----+----+ + // | | | | + // | w4 | w5 | w6 | + // +----+----+----+ + // | | | | + // | w7 | w8 | w9 | + // +----+----+----+ - for (j = 0; j < Yres; j++) { - if (j>0) prevline = -SrcPPL*4; else prevline = 0; - if (j 0) prevline = -SrcPPL * 4; else prevline = 0; + if (j < Yres - 1) nextline = SrcPPL * 4; else nextline = 0; - for (i=0; i0) { - w[1] = *((uint32*)(pIn + prevline - 4)); - w[4] = *((uint32*)(pIn - 4)); - w[7] = *((uint32*)(pIn + nextline - 4)); - } else { - w[1] = w[2]; - w[4] = w[5]; - w[7] = w[8]; - } + if (i > 0) { + w[1] = *((uint32*)(pIn + prevline - 4)); + w[4] = *((uint32*)(pIn - 4)); + w[7] = *((uint32*)(pIn + nextline - 4)); + } + else { + w[1] = w[2]; + w[4] = w[5]; + w[7] = w[8]; + } - if (i trY ) || - ( abs((YUV1 & Umask) - (YUV2 & Umask)) > trU ) || - ( abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV ) ) - pattern |= flag; - } - flag <<= 1; - } + if (w[k] != w[5]) { + YUV2 = RGB888toYUV(w[k]); + if ((abs((YUV1 & Ymask) - (YUV2 & Ymask)) > trY) || + (abs((YUV1 & Umask) - (YUV2 & Umask)) > trU) || + (abs((YUV1 & Vmask) - (YUV2 & Vmask)) > trV)) + pattern |= flag; + } + flag <<= 1; + } - for (k=1; k<=9; k++) - c[k] = w[k]; + for (k = 1; k <= 9; k++) + c[k] = w[k]; #include "TextureFilters_hq4x.h" - pIn+=4; - pOut+=16; - } + pIn += 4; + pOut += 16; + } - pIn += 4*(SrcPPL-Xres); - pOut+= 16*(SrcPPL-Xres); - pOut+=BpL; - pOut+=BpL; - pOut+=BpL; - } + pIn += 4 * (SrcPPL - Xres); + pOut += 16 * (SrcPPL - Xres); + pOut += BpL; + pOut += BpL; + pOut += BpL; + } #undef BPP #undef BPP2 @@ -861,32 +857,32 @@ void hq4x_8888(unsigned char * pIn, unsigned char * pOut, int Xres, int Yres, in #if !_16BPP_HACK void hq4x_init(void) { - static int done = 0; - int r, g, b, Y, u, v, i, j, k; + static int done = 0; + int r, g, b, Y, u, v, i, j, k; - if (done ) return; + if (done) return; - for (i = 0; i < 16; i++) { - for (j = 0; j < 16; j++) { - for (k = 0; k < 16; k++) { - r = (i << 4) | i; - g = (j << 4) | j; - b = (k << 4) | k; + for (i = 0; i < 16; i++) { + for (j = 0; j < 16; j++) { + for (k = 0; k < 16; k++) { + r = (i << 4) | i; + g = (j << 4) | j; + b = (k << 4) | k; - /* Microsoft's RGB888->YUV conversion */ - /*Y = ((( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16) & 0xFF; - u = ((( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128) & 0xFF; - v = ((( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128) & 0xFF;*/ + /* Microsoft's RGB888->YUV conversion */ + /*Y = ((( 66 * r + 129 * g + 25 * b + 128) >> 8) + 16) & 0xFF; + u = ((( -38 * r - 74 * g + 112 * b + 128) >> 8) + 128) & 0xFF; + v = ((( 112 * r - 94 * g - 18 * b + 128) >> 8) + 128) & 0xFF;*/ - Y = (r + g + b) >> 2; - u = 128 + ((r - b) >> 2); - v = 128 + ((-r + 2*g -b)>>3); + Y = (r + g + b) >> 2; + u = 128 + ((r - b) >> 2); + v = 128 + ((-r + 2 * g - b) >> 3); - RGB444toYUV[(i << 8) | (j << 4) | k] = (Y << 16) | (u << 8) | v; - } + RGB444toYUV[(i << 8) | (j << 4) | k] = (Y << 16) | (u << 8) | v; + } + } } - } - done = 1; + done = 1; } -#endif /* !_16BPP_HACK */ +#endif /* !_16BPP_HACK */ \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h index a3a27403c..3eca9cf3e 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_hq4x.h @@ -1,4999 +1,4988 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ -/* Based on Maxim Stepin and Rice1964 hq4x code */ - - switch (pattern) - { - case 0: - case 1: - case 4: - case 32: - case 128: - case 5: - case 132: - case 160: - case 33: - case 129: - case 36: - case 133: - case 164: - case 161: - case 37: - case 165: +switch (pattern) +{ +case 0: +case 1: +case 4: +case 32: +case 128: +case 5: +case 132: +case 160: +case 33: +case 129: +case 36: +case 133: +case 164: +case 161: +case 37: +case 165: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 2: +case 34: +case 130: +case 162: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 16: +case 17: +case 48: +case 49: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 64: +case 65: +case 68: +case 69: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 8: +case 12: +case 136: +case 140: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 3: +case 35: +case 131: +case 163: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 6: +case 38: +case 134: +case 166: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 20: +case 21: +case 52: +case 53: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 144: +case 145: +case 176: +case 177: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 192: +case 193: +case 196: +case 197: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 96: +case 97: +case 100: +case 101: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 40: +case 44: +case 168: +case 172: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 9: +case 13: +case 137: +case 141: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 18: +case 50: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 2: - case 34: - case 130: - case 162: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 16: - case 17: - case 48: - case 49: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 64: - case 65: - case 68: - case 69: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 8: - case 12: - case 136: - case 140: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 3: - case 35: - case 131: - case 163: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 6: - case 38: - case 134: - case 166: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 20: - case 21: - case 52: - case 53: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 144: - case 145: - case 176: - case 177: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 192: - case 193: - case 196: - case 197: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 96: - case 97: - case 100: - case 101: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 40: - case 44: - case 168: - case 172: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 9: - case 13: - case 137: - case 141: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 18: - case 50: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL12_0 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 } - case 80: - case 81: + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 80: +case 81: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { PIXEL22_0 - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 } - case 72: - case 76: + PIXEL30_80 + PIXEL31_10 + break; +} +case 72: +case 76: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_50 - PIXEL21_0 - PIXEL30_50 - PIXEL31_50 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 } - case 10: - case 138: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 10: +case 138: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 66: + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 66: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 24: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 7: +case 39: +case 135: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 148: +case 149: +case 180: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 224: +case 228: +case 225: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 41: +case 169: +case 45: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 22: +case 54: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 24: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 7: - case 39: - case 135: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 148: - case 149: - case 180: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 224: - case 228: - case 225: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 41: - case 169: - case 45: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 22: - case 54: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL13_50 } - case 208: - case 209: + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 208: +case 209: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_50 + PIXEL33_50 } - case 104: - case 108: + PIXEL30_80 + PIXEL31_10 + break; +} +case 104: +case 108: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_0 + PIXEL31_0 } - case 11: - case 139: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 11: +case 139: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 19: - case 51: - { - if (Diff(w[2], w[6])) - { - PIXEL00_81 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 19: +case 51: +{ + if (Diff(w[2], w[6])) + { + PIXEL00_81 PIXEL01_31 PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL00_12 + } + else + { + PIXEL00_12 PIXEL01_14 PIXEL02_83 PIXEL03_50 PIXEL12_70 PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 146: - case 178: + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 146: +case 178: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL23_32 - PIXEL33_82 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } + else + { PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 } - case 84: - case 85: + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; +} +case 84: +case 85: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(w[6], w[8])) - { PIXEL03_81 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 } - case 112: - case 113: + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 112: +case 113: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - } - else - { + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } + else + { PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 } - case 200: - case 204: + break; +} +case 200: +case 204: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 } - case 73: - case 77: + else { - if (Diff(w[8], w[4])) - { - PIXEL00_82 + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; +} +case 73: +case 77: +{ + if (Diff(w[8], w[4])) + { + PIXEL00_82 PIXEL10_32 PIXEL20_10 PIXEL21_30 PIXEL30_80 PIXEL31_10 - } - else - { - PIXEL00_11 + } + else + { + PIXEL00_11 PIXEL10_13 PIXEL20_83 PIXEL21_70 PIXEL30_50 PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 42: - case 170: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 42: +case 170: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 PIXEL20_31 PIXEL30_81 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_21 PIXEL10_83 PIXEL11_70 PIXEL20_14 PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 14: - case 142: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 14: +case 142: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL02_32 PIXEL03_82 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_83 PIXEL02_13 PIXEL03_11 PIXEL10_21 PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 67: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 70: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 28: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 152: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 194: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 98: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 56: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 25: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 26: - case 31: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 67: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 70: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 28: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 152: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 194: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 98: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 56: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 25: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 26: +case 31: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 PIXEL03_0 PIXEL13_0 - } - else - { - PIXEL02_50 + } + else + { + PIXEL02_50 PIXEL03_50 PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 82: - case 214: + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 82: +case 214: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_0 + PIXEL33_0 } - case 88: - case 248: + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 88: +case 248: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; + PIXEL30_0 + PIXEL31_0 } - case 74: - case 107: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 74: +case 107: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 27: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 27: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 86: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 86: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL13_50 } - case 216: + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 216: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_50 + PIXEL33_50 } - case 106: + PIXEL30_80 + PIXEL31_10 + break; +} +case 106: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_0 + PIXEL31_0 } - case 30: + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 30: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL13_50 } - case 210: + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 210: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_50 + PIXEL33_50 } - case 120: + PIXEL30_80 + PIXEL31_10 + break; +} +case 120: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_0 + PIXEL31_0 } - case 75: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 75: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 29: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } - case 198: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 184: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 99: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 57: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 71: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 156: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 226: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 60: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 195: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 102: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 153: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 58: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 29: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 198: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 184: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 99: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 57: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 71: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 156: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 226: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 60: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 195: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 102: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 153: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 58: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 83: + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 83: +{ + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 } - case 92: + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 92: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - break; - } - case 202: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + break; +} +case 202: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 78: + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 78: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 154: + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 154: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 114: + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 114: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 } - case 89: + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 89: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - break; - } - case 90: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + break; +} +case 90: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_10 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 PIXEL21_30 PIXEL30_80 PIXEL31_10 - } - else - { - PIXEL20_12 + } + else + { + PIXEL20_12 PIXEL21_0 PIXEL30_20 PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - break; - } - case 55: - case 23: - { - if (Diff(w[2], w[6])) - { - PIXEL00_81 + } + break; +} +case 55: +case 23: +{ + if (Diff(w[2], w[6])) + { + PIXEL00_81 PIXEL01_31 PIXEL02_0 PIXEL03_0 PIXEL12_0 PIXEL13_0 - } - else - { - PIXEL00_12 + } + else + { + PIXEL00_12 PIXEL01_14 PIXEL02_83 PIXEL03_50 PIXEL12_70 PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } - case 182: - case 150: + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 182: +case 150: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } + else + { PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 } - case 213: - case 212: + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; +} +case 213: +case 212: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(w[6], w[8])) - { PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 } - case 241: - case 240: + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 241: +case 240: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 } - case 236: - case 232: + break; +} +case 236: +case 232: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 } - case 109: - case 105: + else { - if (Diff(w[8], w[4])) - { - PIXEL00_82 + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; +} +case 109: +case 105: +{ + if (Diff(w[8], w[4])) + { + PIXEL00_82 PIXEL10_32 PIXEL20_0 PIXEL21_0 PIXEL30_0 PIXEL31_0 - } - else - { - PIXEL00_11 + } + else + { + PIXEL00_11 PIXEL10_13 PIXEL20_83 PIXEL21_70 PIXEL30_50 PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 171: - case 43: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 171: +case 43: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 PIXEL11_0 PIXEL20_31 PIXEL30_81 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_21 PIXEL10_83 PIXEL11_70 PIXEL20_14 PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 143: - case 15: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 143: +case 15: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL02_32 PIXEL03_82 PIXEL10_0 PIXEL11_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_83 PIXEL02_13 PIXEL03_11 PIXEL10_21 PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } - case 124: + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 124: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_0 + PIXEL31_0 } - case 203: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 203: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 62: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 62: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL13_50 } - case 211: + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 211: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_0 + PIXEL33_0 } - case 118: + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 118: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL03_50 + PIXEL13_50 } - case 217: + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 217: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_0 + PIXEL33_0 } - case 110: + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 110: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_0 + PIXEL31_0 } - case 155: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 155: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 188: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 188: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 185: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 61: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 157: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 103: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 227: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 230: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 199: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 220: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 185: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 61: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 157: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 103: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 227: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 230: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 199: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 220: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 } - case 158: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 158: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 PIXEL03_0 PIXEL13_0 - } - else - { - PIXEL02_50 + } + else + { + PIXEL02_50 PIXEL03_50 PIXEL13_50 - } - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 234: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 234: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(w[8], w[4])) - { + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(w[8], w[4])) + { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { + PIXEL30_0 + PIXEL31_0 + } + else + { PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; + PIXEL30_50 + PIXEL31_50 } - case 242: + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 242: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_82 - PIXEL31_32 - break; + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 } - case 59: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 59: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - PIXEL11_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } - case 121: + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 121: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 87: +{ + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) + { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } + else + { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(w[6], w[8])) + { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 79: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } + else + { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 122: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(w[8], w[4])) + { + PIXEL20_0 PIXEL30_0 PIXEL31_0 - } - else - { - PIXEL20_50 + } + else + { + PIXEL20_50 PIXEL30_50 PIXEL31_50 - } - PIXEL21_0 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 87: + } + PIXEL21_0 + if (Diff(w[6], w[8])) { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { - PIXEL02_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 94: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } + else + { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 PIXEL03_0 PIXEL13_0 - } - else - { - PIXEL02_50 + } + else + { + PIXEL02_50 PIXEL03_50 PIXEL13_50 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - if (Diff(w[6], w[8])) - { - PIXEL22_30 + } + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 79: - { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_32 - PIXEL03_82 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } - case 122: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + break; +} +case 218: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 94: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_10 + } + if (Diff(w[8], w[4])) + { + PIXEL20_10 PIXEL21_30 PIXEL30_80 PIXEL31_10 - } - else - { - PIXEL20_12 + } + else + { + PIXEL20_12 PIXEL21_0 PIXEL30_20 PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } - case 218: + } + PIXEL22_0 + if (Diff(w[6], w[8])) { - if (Diff(w[4], w[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; + PIXEL32_0 + PIXEL33_0 } - case 91: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 91: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - PIXEL11_0 - if (Diff(w[8], w[4])) - { + } + PIXEL11_0 + if (Diff(w[8], w[4])) + { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - break; - } - case 229: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 167: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } - case 173: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 181: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } - case 186: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + break; +} +case 229: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 167: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 173: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 181: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 186: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - if (Diff(w[2], w[6])) - { - PIXEL02_10 + } + if (Diff(w[2], w[6])) + { + PIXEL02_10 PIXEL03_80 PIXEL12_30 PIXEL13_10 - } - else - { - PIXEL02_11 + } + else + { + PIXEL02_11 PIXEL03_20 PIXEL12_0 PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 115: + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 115: +{ + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) + { PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 } - case 93: + else + { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 93: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(w[6], w[8])) - { - PIXEL22_30 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(w[6], w[8])) + { + PIXEL22_30 PIXEL23_10 PIXEL32_10 PIXEL33_80 - } - else - { - PIXEL22_0 + } + else + { + PIXEL22_0 PIXEL23_11 PIXEL32_12 PIXEL33_20 - } - break; - } - case 206: - { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + } + break; +} +case 206: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } - case 205: - case 201: + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - if (Diff(w[8], w[4])) - { PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 } - case 174: - case 46: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_80 + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 205: +case 201: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(w[8], w[4])) + { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } + else + { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 174: +case 46: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_80 PIXEL01_10 PIXEL10_10 PIXEL11_30 - } - else - { - PIXEL00_20 + } + else + { + PIXEL00_20 PIXEL01_12 PIXEL10_11 PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 179: - case 147: + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 179: +case 147: +{ + PIXEL00_81 + PIXEL01_31 + if (Diff(w[2], w[6])) { - PIXEL00_81 - PIXEL01_31 - if (Diff(w[2], w[6])) - { PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } + else + { PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 } - case 117: - case 116: + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 117: +case 116: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } + else + { PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 } - case 189: + PIXEL30_82 + PIXEL31_32 + break; +} +case 189: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 231: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 126: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 231: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } - case 126: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL03_0 + PIXEL13_0 } - case 219: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 219: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } - case 125: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) { - if (Diff(w[8], w[4])) - { - PIXEL00_82 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 125: +{ + if (Diff(w[8], w[4])) + { + PIXEL00_82 PIXEL10_32 PIXEL20_0 PIXEL21_0 PIXEL30_0 PIXEL31_0 - } - else - { - PIXEL00_11 + } + else + { + PIXEL00_11 PIXEL10_13 PIXEL20_83 PIXEL21_70 PIXEL30_50 PIXEL31_21 - } - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 221: + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 221: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(w[6], w[8])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - if (Diff(w[6], w[8])) - { PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 } - case 207: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 207: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL02_32 PIXEL03_82 PIXEL10_0 PIXEL11_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_83 PIXEL02_13 PIXEL03_11 PIXEL10_21 PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } - case 238: + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 238: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } + else + { PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 } - case 190: + PIXEL22_31 + PIXEL23_81 + break; +} +case 190: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_10 - PIXEL11_30 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - break; + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 } - case 187: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; +} +case 187: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 PIXEL11_0 PIXEL20_31 PIXEL30_81 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_21 PIXEL10_83 PIXEL11_70 PIXEL20_14 PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } - case 243: + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 243: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(w[6], w[8])) { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(w[6], w[8])) - { PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 } - case 119: + else { - if (Diff(w[2], w[6])) - { - PIXEL00_81 + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; +} +case 119: +{ + if (Diff(w[2], w[6])) + { + PIXEL00_81 PIXEL01_31 PIXEL02_0 PIXEL03_0 PIXEL12_0 PIXEL13_0 - } - else - { - PIXEL00_12 + } + else + { + PIXEL00_12 PIXEL01_14 PIXEL02_83 PIXEL03_50 PIXEL12_70 PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } - case 237: - case 233: + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 237: +case 233: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { PIXEL30_0 - } - else - { + } + else + { PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; } - case 175: - case 47: + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 175: +case 47: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 183: +case 151: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } - case 183: - case 151: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { PIXEL03_0 - } - else - { + } + else + { PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; } - case 245: - case 244: + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 245: +case 244: +{ + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { PIXEL33_0 - } - else - { + } + else + { PIXEL33_20 - } - break; } - case 250: + break; +} +case 250: +{ + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; + PIXEL30_0 + PIXEL31_0 } - case 123: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 123: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - if (Diff(w[8], w[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 95: + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } + else + { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 95: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - if (Diff(w[2], w[6])) - { - PIXEL02_0 + } + if (Diff(w[2], w[6])) + { + PIXEL02_0 PIXEL03_0 PIXEL13_0 - } - else - { - PIXEL02_50 + } + else + { + PIXEL02_50 PIXEL03_50 PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } - case 222: + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 222: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_0 + PIXEL33_0 } - case 252: + else + { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 252: +{ + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(w[8], w[4])) { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { + PIXEL30_0 + PIXEL31_0 + } + else + { PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { PIXEL33_0 - } - else - { + } + else + { PIXEL33_20 - } - break; } - case 249: + break; +} +case 249: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; + PIXEL32_0 + PIXEL33_0 } - case 235: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; +} +case 235: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) + { PIXEL30_0 - } - else - { + } + else + { PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; } - case 111: + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 111: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(w[8], w[4])) - { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { + PIXEL30_0 + PIXEL31_0 + } + else + { PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_50 + PIXEL31_50 } - case 63: + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 63: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; + PIXEL03_0 + PIXEL13_0 } - case 159: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 159: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_0 - if (Diff(w[2], w[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } - case 215: + } + PIXEL02_0 + if (Diff(w[2], w[6])) { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { PIXEL03_0 - } - else - { + } + else + { PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 215: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) + { + PIXEL03_0 + } + else + { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_50 + PIXEL33_50 } - case 246: + PIXEL30_80 + PIXEL31_10 + break; +} +case 246: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; } - case 254: + else + { + PIXEL33_20 + } + break; +} +case 254: +{ + PIXEL00_80 + PIXEL01_10 + if (Diff(w[2], w[6])) { - PIXEL00_80 - PIXEL01_10 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(w[8], w[4])) - { + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(w[8], w[4])) + { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { + PIXEL30_0 + PIXEL31_0 + } + else + { PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; + PIXEL30_50 + PIXEL31_50 } - case 253: + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; +} +case 253: +{ + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(w[8], w[4])) - { PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; } - case 251: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; +} +case 251: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(w[6], w[8])) - { + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(w[6], w[8])) + { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(w[8], w[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; + PIXEL32_50 + PIXEL33_50 } - case 239: + if (Diff(w[8], w[4])) + { + PIXEL30_0 + } + else + { + PIXEL30_20 + } + PIXEL31_0 + break; +} +case 239: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(w[8], w[4])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(w[8], w[4])) - { PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; } - case 127: + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 127: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(w[2], w[6])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(w[2], w[6])) - { PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { + PIXEL03_0 + PIXEL13_0 + } + else + { PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - if (Diff(w[8], w[4])) - { + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(w[8], w[4])) + { PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { + PIXEL30_0 + PIXEL31_0 + } + else + { PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; + PIXEL30_50 + PIXEL31_50 } - case 191: + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 191: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(w[2], w[6])) - { PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; } - case 223: + else { - if (Diff(w[4], w[2])) - { - PIXEL00_0 + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 223: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 PIXEL01_0 PIXEL10_0 - } - else - { - PIXEL00_50 + } + else + { + PIXEL00_50 PIXEL01_50 PIXEL10_50 - } - PIXEL02_0 - if (Diff(w[2], w[6])) - { + } + PIXEL02_0 + if (Diff(w[2], w[6])) + { PIXEL03_0 - } - else - { + } + else + { PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(w[6], w[8])) - { + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(w[6], w[8])) + { PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { + PIXEL32_0 + PIXEL33_0 + } + else + { PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; + PIXEL32_50 + PIXEL33_50 } - case 247: + PIXEL30_80 + PIXEL31_10 + break; +} +case 247: +{ + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(w[2], w[6])) { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(w[2], w[6])) - { PIXEL03_0 - } - else - { + } + else + { PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(w[6], w[8])) - { + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(w[6], w[8])) + { PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; } - case 255: + else + { + PIXEL33_20 + } + break; +} +case 255: +{ + if (Diff(w[4], w[2])) + { + PIXEL00_0 + } + else + { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(w[2], w[6])) { - if (Diff(w[4], w[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(w[2], w[6])) - { PIXEL03_0 - } - else - { + } + else + { PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(w[8], w[4])) - { + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(w[8], w[4])) + { PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(w[6], w[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; } - } + else + { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(w[6], w[8])) + { + PIXEL33_0 + } + else + { + PIXEL33_20 + } + break; +} +} diff --git a/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h b/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h index b5318ab81..4c32d377c 100644 --- a/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h +++ b/Source/Project64-video/TextureEnhancer/TextureFilters_lq2x.h @@ -1,1307 +1,1433 @@ -/* -Copyright (C) 2003 Rice1964 +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 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-1307, USA. - -*/ - -/* Copyright (C) 2007 Hiroshi Morii - * Modified for the Texture Filtering library - */ - -case 0 : -case 2 : -case 4 : -case 6 : -case 8 : -case 12 : -case 16 : -case 20 : -case 24 : -case 28 : -case 32 : -case 34 : -case 36 : -case 38 : -case 40 : -case 44 : -case 48 : -case 52 : -case 56 : -case 60 : -case 64 : -case 66 : -case 68 : -case 70 : -case 96 : -case 98 : -case 100 : -case 102 : -case 128 : -case 130 : -case 132 : -case 134 : -case 136 : -case 140 : -case 144 : -case 148 : -case 152 : -case 156 : -case 160 : -case 162 : -case 164 : -case 166 : -case 168 : -case 172 : -case 176 : -case 180 : -case 184 : -case 188 : -case 192 : -case 194 : -case 196 : -case 198 : -case 224 : -case 226 : -case 228 : -case 230 : +case 0: +case 2: +case 4: +case 6: +case 8: +case 12: +case 16: +case 20: +case 24: +case 28: +case 32: +case 34: +case 36: +case 38: +case 40: +case 44: +case 48: +case 52: +case 56: +case 60: +case 64: +case 66: +case 68: +case 70: +case 96: +case 98: +case 100: +case 102: +case 128: +case 130: +case 132: +case 134: +case 136: +case 140: +case 144: +case 148: +case 152: +case 156: +case 160: +case 162: +case 164: +case 166: +case 168: +case 172: +case 176: +case 180: +case 184: +case 188: +case 192: +case 194: +case 196: +case 198: +case 224: +case 226: +case 228: +case 230: { - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); -} break; -case 1 : -case 5 : -case 9 : -case 13 : -case 17 : -case 21 : -case 25 : -case 29 : -case 33 : -case 37 : -case 41 : -case 45 : -case 49 : -case 53 : -case 57 : -case 61 : -case 65 : -case 69 : -case 97 : -case 101 : -case 129 : -case 133 : -case 137 : -case 141 : -case 145 : -case 149 : -case 153 : -case 157 : -case 161 : -case 165 : -case 169 : -case 173 : -case 177 : -case 181 : -case 185 : -case 189 : -case 193 : -case 197 : -case 225 : -case 229 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - P3 = IC(1); -} break; -case 3 : -case 35 : -case 67 : -case 99 : -case 131 : -case 163 : -case 195 : -case 227 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); -} break; -case 7 : -case 39 : -case 71 : -case 103 : -case 135 : -case 167 : -case 199 : -case 231 : -{ - P0 = IC(3); - P1 = IC(3); - P2 = IC(3); - P3 = IC(3); -} break; -case 10 : -case 138 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 11 : -case 27 : -case 75 : -case 139 : -case 155 : -case 203 : -{ - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { P0 = IC(0); P1 = IC(0); - } else { - P0 = I332(1, 3, 0); - P1 = I31(0, 1); - } + P2 = IC(0); + P3 = IC(0); } break; -case 15 : -case 143 : -case 207 : +case 1: +case 5: +case 9: +case 13: +case 17: +case 21: +case 25: +case 29: +case 33: +case 37: +case 41: +case 45: +case 49: +case 53: +case 57: +case 61: +case 65: +case 69: +case 97: +case 101: +case 129: +case 133: +case 137: +case 141: +case 145: +case 149: +case 153: +case 157: +case 161: +case 165: +case 169: +case 173: +case 177: +case 181: +case 185: +case 189: +case 193: +case 197: +case 225: +case 229: { - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - P1 = IC(4); - } else { - P0 = I332(1, 3, 4); - P1 = I31(4, 1); - } + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + P3 = IC(1); } break; -case 18 : -case 22 : -case 30 : -case 50 : -case 54 : -case 62 : -case 86 : -case 118 : +case 3: +case 35: +case 67: +case 99: +case 131: +case 163: +case 195: +case 227: { - P0 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 19 : -case 51 : -{ - P2 = IC(2); - P3 = IC(2); - if (HQ2X_MUR) { P0 = IC(2); P1 = IC(2); - } else { - P0 = I31(2, 1); - P1 = I332(1, 5, 2); - } + P2 = IC(2); + P3 = IC(2); } break; -case 23 : -case 55 : -case 119 : +case 7: +case 39: +case 71: +case 103: +case 135: +case 167: +case 199: +case 231: { - P2 = IC(3); - P3 = IC(3); - if (HQ2X_MUR) { P0 = IC(3); P1 = IC(3); - } else { - P0 = I31(3, 1); - P1 = I332(1, 5, 3); - } + P2 = IC(3); + P3 = IC(3); } break; -case 26 : +case 10: +case 138: { - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } - if (HQ2X_MUR) { P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 31 : -case 95 : -{ - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 42 : -case 170 : -{ - P1 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); P2 = IC(0); - } else { - P0 = I332(1, 3, 0); - P2 = I31(0, 3); - } + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I211(0, 1, 3); + } } break; -case 43 : -case 171 : -case 187 : +case 11: +case 27: +case 75: +case 139: +case 155: +case 203: { - P1 = IC(2); - P3 = IC(2); - if (HQ2X_MUL) { - P0 = IC(2); + P1 = IC(2); P2 = IC(2); - } else { - P0 = I332(1, 3, 2); - P2 = I31(2, 3); - } -} break; -case 46 : -case 174 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = IC(4); - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 58 : -case 154 : -case 186 : -{ - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 59 : -{ - P2 = IC(2); - P3 = IC(2); - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 63 : -{ - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 72 : -case 76 : -case 104 : -case 106 : -case 108 : -case 110 : -case 120 : -case 124 : -{ - P0 = IC(0); - P1 = IC(0); - P3 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } -} break; -case 73 : -case 77 : -case 105 : -case 109 : -case 125 : -{ - P1 = IC(1); - P3 = IC(1); - if (HQ2X_MDL) { - P0 = IC(1); - P2 = IC(1); - } else { - P0 = I31(1, 3); - P2 = I332(3, 7, 1); - } -} break; -case 74 : -{ - P1 = IC(0); - P3 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 78 : -case 202 : -case 206 : -{ - P1 = IC(0); - P3 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 79 : -{ - P1 = IC(4); - P3 = IC(4); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I611(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 208 : -case 210 : -case 216 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 81 : -case 209 : -case 217 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 82 : -case 214 : -case 222 : -{ - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 83 : -case 115 : -{ - P0 = IC(2); - P2 = IC(2); - if (HQ2X_MDR) { P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } } break; -case 84 : -case 212 : +case 14: +case 142: +{ + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + P1 = IC(0); + } + else { + P0 = I332(1, 3, 0); + P1 = I31(0, 1); + } +} break; +case 15: +case 143: +case 207: +{ + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + P1 = IC(4); + } + else { + P0 = I332(1, 3, 4); + P1 = I31(4, 1); + } +} break; +case 18: +case 22: +case 30: +case 50: +case 54: +case 62: +case 86: +case 118: +{ + P0 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 19: +case 51: +{ + P2 = IC(2); + P3 = IC(2); + if (HQ2X_MUR) { + P0 = IC(2); + P1 = IC(2); + } + else { + P0 = I31(2, 1); + P1 = I332(1, 5, 2); + } +} break; +case 23: +case 55: +case 119: +{ + P2 = IC(3); + P3 = IC(3); + if (HQ2X_MUR) { + P0 = IC(3); + P1 = IC(3); + } + else { + P0 = I31(3, 1); + P1 = I332(1, 5, 3); + } +} break; +case 26: +{ + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I211(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 31: +case 95: +{ + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 42: +case 170: { - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { P1 = IC(0); P3 = IC(0); - } else { - P1 = I31(0, 5); - P3 = I332(5, 7, 0); - } + if (HQ2X_MUL) { + P0 = IC(0); + P2 = IC(0); + } + else { + P0 = I332(1, 3, 0); + P2 = I31(0, 3); + } } break; -case 85 : -case 213 : -case 221 : +case 43: +case 171: +case 187: +{ + P1 = IC(2); + P3 = IC(2); + if (HQ2X_MUL) { + P0 = IC(2); + P2 = IC(2); + } + else { + P0 = I332(1, 3, 2); + P2 = I31(2, 3); + } +} break; +case 46: +case 174: +{ + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } +} break; +case 47: +case 175: +{ + P1 = IC(4); + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 58: +case 154: +case 186: +{ + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 59: +{ + P2 = IC(2); + P3 = IC(2); + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(2); + } + else { + P1 = I611(2, 1, 5); + } +} break; +case 63: +{ + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 72: +case 76: +case 104: +case 106: +case 108: +case 110: +case 120: +case 124: +{ + P0 = IC(0); + P1 = IC(0); + P3 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } +} break; +case 73: +case 77: +case 105: +case 109: +case 125: { - P0 = IC(1); - P2 = IC(1); - if (HQ2X_MDR) { P1 = IC(1); P3 = IC(1); - } else { - P1 = I31(1, 5); - P3 = I332(5, 7, 1); - } + if (HQ2X_MDL) { + P0 = IC(1); + P2 = IC(1); + } + else { + P0 = I31(1, 3); + P2 = I332(3, 7, 1); + } } break; -case 87 : +case 74: { - P0 = IC(3); - P2 = IC(3); - if (HQ2X_MDR) { - P3 = IC(3); - } else { - P3 = I611(3, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(3); - } else { - P1 = I211(3, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 89 : -case 93 : -{ - P0 = IC(1); - P1 = IC(1); - if (HQ2X_MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 90 : -{ - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 91 : -{ - if (HQ2X_MDL) { - P2 = IC(2); - } else { - P2 = I611(2, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 92 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MDR) { P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I211(0, 1, 3); + } } break; -case 94 : +case 78: +case 202: +case 206: { - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 107 : -case 123 : -{ - P1 = IC(2); - P3 = IC(2); - if (HQ2X_MDL) { - P2 = IC(2); - } else { - P2 = I211(2, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 111 : -{ - P1 = IC(4); - P3 = IC(4); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 240 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDR) { - P2 = IC(0); P3 = IC(0); - } else { - P2 = I31(0, 7); - P3 = I332(5, 7, 0); - } + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } } break; -case 113 : -case 241 : +case 79: { - P0 = IC(1); - P1 = IC(1); - if (HQ2X_MDR) { - P2 = IC(1); - P3 = IC(1); - } else { - P2 = I31(1, 7); - P3 = I332(5, 7, 1); - } -} break; -case 114 : -{ - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 116 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } -} break; -case 117 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 121 : -{ - P0 = IC(1); - P1 = IC(1); - if (HQ2X_MDL) { - P2 = IC(1); - } else { - P2 = I211(1, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 122 : -{ - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 126 : -{ - P0 = IC(0); - P3 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 127 : -{ - P3 = IC(4); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 146 : -case 150 : -case 178 : -case 182 : -case 190 : -{ - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MUR) { - P1 = IC(0); - P3 = IC(0); - } else { - P1 = I332(1, 5, 0); - P3 = I31(0, 5); - } -} break; -case 147 : -case 179 : -{ - P0 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (HQ2X_MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 151 : -case 183 : -{ - P0 = IC(3); - P2 = IC(3); - P3 = IC(3); - if (HQ2X_MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 158 : -{ - P2 = IC(0); - P3 = IC(0); - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 159 : -{ - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 191 : -{ - P2 = IC(4); - P3 = IC(4); - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 200 : -case 204 : -case 232 : -case 236 : -case 238 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - P3 = IC(0); - } else { - P2 = I332(3, 7, 0); - P3 = I31(0, 7); - } -} break; -case 201 : -case 205 : -{ - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (HQ2X_MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } -} break; -case 211 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - if (HQ2X_MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } -} break; -case 215 : -{ - P0 = IC(3); - P2 = IC(3); - if (HQ2X_MDR) { - P3 = IC(3); - } else { - P3 = I211(3, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 218 : -{ - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 219 : -{ - P1 = IC(2); - P2 = IC(2); - if (HQ2X_MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 220 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 223 : -{ - P2 = IC(4); - if (HQ2X_MDR) { P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (HQ2X_MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I611(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } } break; -case 233 : -case 237 : +case 80: +case 208: +case 210: +case 216: { - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (HQ2X_MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } -} break; -case 234 : -{ - P1 = IC(0); - P3 = IC(0); - if (HQ2X_MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MUL) { P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 235 : -{ - P1 = IC(2); - P3 = IC(2); - if (HQ2X_MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 239 : -{ - P1 = IC(4); - P3 = IC(4); - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 242 : -{ - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (HQ2X_MUR) { P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 243 : -{ - P0 = IC(2); - P1 = IC(2); - if (HQ2X_MDR) { - P2 = IC(2); - P3 = IC(2); - } else { - P2 = I31(2, 7); - P3 = I332(5, 7, 2); - } -} break; -case 244 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } -} break; -case 245 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } -} break; -case 246 : -{ - P0 = IC(0); - P2 = IC(0); - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 247 : -{ - P0 = IC(3); - P2 = IC(3); - if (HQ2X_MDR) { - P3 = IC(3); - } else { - P3 = I1411(3, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 249 : -{ - P0 = IC(1); - P1 = IC(1); - if (HQ2X_MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 251 : -{ - P1 = IC(2); - if (HQ2X_MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 252 : -{ - P0 = IC(0); - P1 = IC(0); - if (HQ2X_MDL) { P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } } break; -case 253 : +case 81: +case 209: +case 217: { - P0 = IC(1); - P1 = IC(1); - if (HQ2X_MDL) { + P0 = IC(1); + P1 = IC(1); P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I211(1, 5, 7); + } } break; -case 254 : +case 82: +case 214: +case 222: { - P0 = IC(0); - if (HQ2X_MDL) { + P0 = IC(0); P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (HQ2X_MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } } break; -case 255 : +case 83: +case 115: +{ + P0 = IC(2); + P2 = IC(2); + if (HQ2X_MDR) { + P3 = IC(2); + } + else { + P3 = I611(2, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(2); + } + else { + P1 = I611(2, 1, 5); + } +} break; +case 84: +case 212: +{ + P0 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P1 = IC(0); + P3 = IC(0); + } + else { + P1 = I31(0, 5); + P3 = I332(5, 7, 0); + } +} break; +case 85: +case 213: +case 221: +{ + P0 = IC(1); + P2 = IC(1); + if (HQ2X_MDR) { + P1 = IC(1); + P3 = IC(1); + } + else { + P1 = I31(1, 5); + P3 = I332(5, 7, 1); + } +} break; +case 87: +{ + P0 = IC(3); + P2 = IC(3); + if (HQ2X_MDR) { + P3 = IC(3); + } + else { + P3 = I611(3, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(3); + } + else { + P1 = I211(3, 1, 5); + } +} break; +case 88: +case 248: +case 250: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } +} break; +case 89: +case 93: +{ + P0 = IC(1); + P1 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I611(1, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I611(1, 5, 7); + } +} break; +case 90: +{ + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 91: +{ + if (HQ2X_MDL) { + P2 = IC(2); + } + else { + P2 = I611(2, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(2); + } + else { + P3 = I611(2, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(2); + } + else { + P1 = I611(2, 1, 5); + } +} break; +case 92: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } +} break; +case 94: +{ + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 107: +case 123: +{ + P1 = IC(2); + P3 = IC(2); + if (HQ2X_MDL) { + P2 = IC(2); + } + else { + P2 = I211(2, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } +} break; +case 111: { - if (HQ2X_MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (HQ2X_MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (HQ2X_MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (HQ2X_MUR) { P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } + P3 = IC(4); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 112: +case 240: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDR) { + P2 = IC(0); + P3 = IC(0); + } + else { + P2 = I31(0, 7); + P3 = I332(5, 7, 0); + } +} break; +case 113: +case 241: +{ + P0 = IC(1); + P1 = IC(1); + if (HQ2X_MDR) { + P2 = IC(1); + P3 = IC(1); + } + else { + P2 = I31(1, 7); + P3 = I332(5, 7, 1); + } +} break; +case 114: +{ + P0 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 116: +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } +} break; +case 117: +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I611(1, 5, 7); + } +} break; +case 121: +{ + P0 = IC(1); + P1 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I211(1, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I611(1, 5, 7); + } +} break; +case 122: +{ + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I611(0, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 126: +{ + P0 = IC(0); + P3 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 127: +{ + P3 = IC(4); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I211(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I211(4, 1, 5); + } +} break; +case 146: +case 150: +case 178: +case 182: +case 190: +{ + P0 = IC(0); + P2 = IC(0); + if (HQ2X_MUR) { + P1 = IC(0); + P3 = IC(0); + } + else { + P1 = I332(1, 5, 0); + P3 = I31(0, 5); + } +} break; +case 147: +case 179: +{ + P0 = IC(2); + P2 = IC(2); + P3 = IC(2); + if (HQ2X_MUR) { + P1 = IC(2); + } + else { + P1 = I611(2, 1, 5); + } +} break; +case 151: +case 183: +{ + P0 = IC(3); + P2 = IC(3); + P3 = IC(3); + if (HQ2X_MUR) { + P1 = IC(3); + } + else { + P1 = I1411(3, 1, 5); + } +} break; +case 158: +{ + P2 = IC(0); + P3 = IC(0); + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 159: +{ + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 191: +{ + P2 = IC(4); + P3 = IC(4); + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 200: +case 204: +case 232: +case 236: +case 238: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + P3 = IC(0); + } + else { + P2 = I332(3, 7, 0); + P3 = I31(0, 7); + } +} break; +case 201: +case 205: +{ + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I611(1, 3, 7); + } +} break; +case 211: +{ + P0 = IC(2); + P1 = IC(2); + P2 = IC(2); + if (HQ2X_MDR) { + P3 = IC(2); + } + else { + P3 = I211(2, 5, 7); + } +} break; +case 215: +{ + P0 = IC(3); + P2 = IC(3); + if (HQ2X_MDR) { + P3 = IC(3); + } + else { + P3 = I211(3, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(3); + } + else { + P1 = I1411(3, 1, 5); + } +} break; +case 218: +{ + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 219: +{ + P1 = IC(2); + P2 = IC(2); + if (HQ2X_MDR) { + P3 = IC(2); + } + else { + P3 = I211(2, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } +} break; +case 220: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I611(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } +} break; +case 223: +{ + P2 = IC(4); + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I211(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I211(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } +} break; +case 233: +case 237: +{ + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I1411(1, 3, 7); + } +} break; +case 234: +{ + P1 = IC(0); + P3 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(0); + } + else { + P0 = I611(0, 1, 3); + } +} break; +case 235: +{ + P1 = IC(2); + P3 = IC(2); + if (HQ2X_MDL) { + P2 = IC(2); + } + else { + P2 = I1411(2, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } +} break; +case 239: +{ + P1 = IC(4); + P3 = IC(4); + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } +} break; +case 242: +{ + P0 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I211(0, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I611(0, 1, 5); + } +} break; +case 243: +{ + P0 = IC(2); + P1 = IC(2); + if (HQ2X_MDR) { + P2 = IC(2); + P3 = IC(2); + } + else { + P2 = I31(2, 7); + P3 = I332(5, 7, 2); + } +} break; +case 244: +{ + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I1411(0, 5, 7); + } +} break; +case 245: +{ + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I1411(1, 5, 7); + } +} break; +case 246: +{ + P0 = IC(0); + P2 = IC(0); + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I1411(0, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 247: +{ + P0 = IC(3); + P2 = IC(3); + if (HQ2X_MDR) { + P3 = IC(3); + } + else { + P3 = I1411(3, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(3); + } + else { + P1 = I1411(3, 1, 5); + } +} break; +case 249: +{ + P0 = IC(1); + P1 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I1411(1, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I211(1, 5, 7); + } +} break; +case 251: +{ + P1 = IC(2); + if (HQ2X_MDL) { + P2 = IC(2); + } + else { + P2 = I1411(2, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(2); + } + else { + P3 = I211(2, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(2); + } + else { + P0 = I211(2, 1, 3); + } +} break; +case 252: +{ + P0 = IC(0); + P1 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I1411(0, 5, 7); + } +} break; +case 253: +{ + P0 = IC(1); + P1 = IC(1); + if (HQ2X_MDL) { + P2 = IC(1); + } + else { + P2 = I1411(1, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(1); + } + else { + P3 = I1411(1, 5, 7); + } +} break; +case 254: +{ + P0 = IC(0); + if (HQ2X_MDL) { + P2 = IC(0); + } + else { + P2 = I211(0, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(0); + } + else { + P3 = I1411(0, 5, 7); + } + if (HQ2X_MUR) { + P1 = IC(0); + } + else { + P1 = I211(0, 1, 5); + } +} break; +case 255: +{ + if (HQ2X_MDL) { + P2 = IC(4); + } + else { + P2 = I1411(4, 3, 7); + } + if (HQ2X_MDR) { + P3 = IC(4); + } + else { + P3 = I1411(4, 5, 7); + } + if (HQ2X_MUL) { + P0 = IC(4); + } + else { + P0 = I1411(4, 1, 3); + } + if (HQ2X_MUR) { + P1 = IC(4); + } + else { + P1 = I1411(4, 1, 5); + } } break; diff --git a/Source/Project64-video/TextureEnhancer/TxCache.cpp b/Source/Project64-video/TextureEnhancer/TxCache.cpp index e65a67eaa..e03c3370e 100644 --- a/Source/Project64-video/TextureEnhancer/TxCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxCache.cpp @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef WIN32 #pragma warning(disable: 4786) @@ -33,6 +24,7 @@ #include #include #include +#include TxCache::~TxCache() { @@ -82,8 +74,8 @@ TxCache::TxCache(int options, int cachesize, const char *path, const char *ident } } -boolean -TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) +bool +TxCache::add(uint64_t checksum, GHQTexInfo *info, int dataSize) { /* NOTE: dataSize must be provided if info->data is zlib compressed. */ @@ -112,7 +104,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) { DBG_INFO(80, "zlib compressed: %.02fkb->%.02fkb\n", (float)dataSize / 1000, (float)destLen / 1000); dataSize = destLen; - format |= GR_TEXFMT_GZ; + format |= GFX_TEXFMT_GZ; } } } @@ -124,11 +116,11 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) if ((_totalSize > _cacheSize) && !_cachelist.empty()) { /* _cachelist is arranged so that frequently used textures are in the back */ - std::list::iterator itList = _cachelist.begin(); + std::list::iterator itList = _cachelist.begin(); while (itList != _cachelist.end()) { /* find it in _cache */ - std::map::iterator itMap = _cache.find(*itList); + std::map::iterator itMap = _cache.find(*itList); if (itMap != _cache.end()) { /* yep we have it. remove it. */ @@ -176,7 +168,7 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) txCache->it = --(_cachelist.end()); } /* _cache[checksum] = txCache; */ - _cache.insert(std::map::value_type(checksum, txCache)); + _cache.insert(std::map::value_type(checksum, txCache)); #ifdef DEBUG DBG_INFO(80, "[%5d] added!! crc:%08X %08X %d x %d gfmt:%x total:%.02fmb\n", @@ -213,13 +205,13 @@ TxCache::add(uint64 checksum, GHQTexInfo *info, int dataSize) return 0; } -boolean -TxCache::get(uint64 checksum, GHQTexInfo *info) +bool +TxCache::get(uint64_t checksum, GHQTexInfo *info) { if (!checksum || _cache.empty()) return 0; /* find a match in cache */ - std::map::iterator itMap = _cache.find(checksum); + std::map::iterator itMap = _cache.find(checksum); if (itMap != _cache.end()) { /* yep, we've got it. */ @@ -234,7 +226,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info) } /* zlib decompress it */ - if (info->format & GR_TEXFMT_GZ) + if (info->format & GFX_TEXFMT_GZ) { uLongf destLen = _gzdestLen; uint8 *dest = (_gzdest0 == info->data) ? _gzdest1 : _gzdest0; @@ -244,7 +236,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info) return 0; } info->data = dest; - info->format &= ~GR_TEXFMT_GZ; + info->format &= ~GFX_TEXFMT_GZ; DBG_INFO(80, "zlib decompressed: %.02fkb->%.02fkb\n", (float)(((*itMap).second)->size) / 1000, (float)destLen / 1000); } return 1; @@ -252,7 +244,7 @@ TxCache::get(uint64 checksum, GHQTexInfo *info) return 0; } -boolean TxCache::save(const char *path, const char *filename, int config) +bool TxCache::save(const char *path, const char *filename, int config) { if (!_cache.empty()) { @@ -265,7 +257,7 @@ boolean TxCache::save(const char *path, const char *filename, int config) /* write header to determine config match */ gzwrite(gzfp, &config, 4); - std::map::iterator itMap = _cache.begin(); + std::map::iterator itMap = _cache.begin(); while (itMap != _cache.end()) { uint8 *dest = (*itMap).second->info.data; @@ -277,17 +269,17 @@ boolean TxCache::save(const char *path, const char *filename, int config) * texture data in a zlib compressed state. if the GZ_TEXCACHE or GZ_HIRESTEXCACHE * option is toggled, the cache will need to be rebuilt. */ - /*if (format & GR_TEXFMT_GZ) { - dest = _gzdest0; - destLen = _gzdestLen; - if (dest && destLen) { - if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) { - dest = NULL; - destLen = 0; - } - format &= ~GR_TEXFMT_GZ; - } - }*/ + /*if (format & GFX_TEXFMT_GZ) { + dest = _gzdest0; + destLen = _gzdestLen; + if (dest && destLen) { + if (uncompress(dest, &destLen, (*itMap).second->info.data, (*itMap).second->size) != Z_OK) { + dest = NULL; + destLen = 0; + } + format &= ~GFX_TEXFMT_GZ; + } + }*/ if (dest && destLen) { @@ -325,7 +317,7 @@ boolean TxCache::save(const char *path, const char *filename, int config) return _cache.empty(); } -boolean TxCache::load(const char *path, const char *filename, int config) +bool TxCache::load(const char *path, const char *filename, int config) { /* find it on disk */ CPath cbuf(path, filename); @@ -336,7 +328,7 @@ boolean TxCache::load(const char *path, const char *filename, int config) { /* yep, we have it. load it into memory cache. */ int dataSize; - uint64 checksum; + uint64_t checksum; GHQTexInfo tmpInfo; int tmpconfig; /* read header to determine config match */ @@ -372,7 +364,7 @@ boolean TxCache::load(const char *path, const char *filename, int config) gzread(gzfp, tmpInfo.data, dataSize); /* add to memory cache */ - add(checksum, &tmpInfo, (tmpInfo.format & GR_TEXFMT_GZ) ? dataSize : 0); + add(checksum, &tmpInfo, (tmpInfo.format & GFX_TEXFMT_GZ) ? dataSize : 0); free(tmpInfo.data); } @@ -391,11 +383,11 @@ boolean TxCache::load(const char *path, const char *filename, int config) return !_cache.empty(); } -boolean TxCache::del(uint64 checksum) +bool TxCache::del(uint64_t checksum) { if (!checksum || _cache.empty()) return 0; - std::map::iterator itMap = _cache.find(checksum); + std::map::iterator itMap = _cache.find(checksum); if (itMap != _cache.end()) { /* for texture cache (not hi-res cache) */ @@ -415,9 +407,9 @@ boolean TxCache::del(uint64 checksum) return 0; } -boolean TxCache::is_cached(uint64 checksum) +bool TxCache::is_cached(uint64_t checksum) { - std::map::iterator itMap = _cache.find(checksum); + std::map::iterator itMap = _cache.find(checksum); if (itMap != _cache.end()) return 1; return 0; @@ -427,7 +419,7 @@ void TxCache::clear() { if (!_cache.empty()) { - std::map::iterator itMap = _cache.begin(); + std::map::iterator itMap = _cache.begin(); while (itMap != _cache.end()) { free((*itMap).second->info.data); diff --git a/Source/Project64-video/TextureEnhancer/TxCache.h b/Source/Project64-video/TextureEnhancer/TxCache.h index 5cb890a1d..2b8112dda 100644 --- a/Source/Project64-video/TextureEnhancer/TxCache.h +++ b/Source/Project64-video/TextureEnhancer/TxCache.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXCACHE_H__ #define __TXCACHE_H__ @@ -33,37 +24,37 @@ class TxCache { private: - std::list _cachelist; - uint8 *_gzdest0; - uint8 *_gzdest1; - uint32 _gzdestLen; + std::list _cachelist; + uint8 *_gzdest0; + uint8 *_gzdest1; + uint32 _gzdestLen; protected: - int _options; - std::string _ident; - std::string _path; - dispInfoFuncExt _callback; - TxUtil *_txUtil; - struct TXCACHE { - int size; - GHQTexInfo info; - std::list::iterator it; - }; - int _totalSize; - int _cacheSize; - std::map _cache; - boolean save(const char *path, const char *filename, const int config); - boolean load(const char *path, const char *filename, const int config); - boolean del(uint64 checksum); /* checksum hi:palette low:texture */ - boolean is_cached(uint64 checksum); /* checksum hi:palette low:texture */ - void clear(); + int _options; + std::string _ident; + std::string _path; + dispInfoFuncExt _callback; + TxUtil *_txUtil; + struct TXCACHE { + int size; + GHQTexInfo info; + std::list::iterator it; + }; + int _totalSize; + int _cacheSize; + std::map _cache; + bool save(const char *path, const char *filename, const int config); + bool load(const char *path, const char *filename, const int config); + bool del(uint64_t checksum); /* checksum hi:palette low:texture */ + bool is_cached(uint64_t checksum); /* checksum hi:palette low:texture */ + void clear(); public: - ~TxCache(); - TxCache(int options, int cachesize, const char *path, const char *ident, - dispInfoFuncExt callback); - boolean add(uint64 checksum, /* checksum hi:palette low:texture */ - GHQTexInfo *info, int dataSize = 0); - boolean get(uint64 checksum, /* checksum hi:palette low:texture */ - GHQTexInfo *info); + ~TxCache(); + TxCache(int options, int cachesize, const char *path, const char *ident, + dispInfoFuncExt callback); + bool add(uint64_t checksum, /* checksum hi:palette low:texture */ + GHQTexInfo *info, int dataSize = 0); + bool get(uint64_t checksum, /* checksum hi:palette low:texture */ + GHQTexInfo *info); }; #endif /* __TXCACHE_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxDbg.cpp b/Source/Project64-video/TextureEnhancer/TxDbg.cpp index a30c00f6f..1d0877bb6 100644 --- a/Source/Project64-video/TextureEnhancer/TxDbg.cpp +++ b/Source/Project64-video/TextureEnhancer/TxDbg.cpp @@ -1,26 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #define DBG_LEVEL 80 #include "TxDbg.h" @@ -49,7 +39,7 @@ TxDbg::TxDbg() TxDbg::~TxDbg() { - if (_dbgfile) + if (_dbgfile) { fclose(_dbgfile); _dbgfile = 0; diff --git a/Source/Project64-video/TextureEnhancer/TxDbg.h b/Source/Project64-video/TextureEnhancer/TxDbg.h index 37ad82a32..b170297ca 100644 --- a/Source/Project64-video/TextureEnhancer/TxDbg.h +++ b/Source/Project64-video/TextureEnhancer/TxDbg.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXDBG_H__ #define __TXDBG_H__ @@ -30,16 +21,16 @@ class TxDbg { private: - FILE* _dbgfile; - int _level; - TxDbg(); + FILE* _dbgfile; + int _level; + TxDbg(); public: - static TxDbg* getInstance() { - static TxDbg txDbg; - return &txDbg; - } - ~TxDbg(); - void output(const int level, const char *format, ...); + static TxDbg* getInstance() { + static TxDbg txDbg; + return &txDbg; + } + ~TxDbg(); + void output(const int level, const char *format, ...); }; #ifdef DEBUG diff --git a/Source/Project64-video/TextureEnhancer/TxFilter.cpp b/Source/Project64-video/TextureEnhancer/TxFilter.cpp index 92e8bd969..dc594f094 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilter.cpp +++ b/Source/Project64-video/TextureEnhancer/TxFilter.cpp @@ -1,32 +1,23 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #pragma warning(disable: 4786) #endif #include #include +#include #include "TxFilter.h" #include "TextureFilters.h" #include "TxDbg.h" @@ -173,8 +164,8 @@ TxFilter::TxFilter(int maxwidth, int maxheight, int maxbpp, int options, _initialized = 1; } -boolean -TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64 g64crc, GHQTexInfo *info) +bool +TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint64_t g64crc, GHQTexInfo *info) { uint8 *texture = src; uint8 *tmptex = _tex1; @@ -187,7 +178,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint if (_cacheSize) { /* calculate checksum of source texture */ if (!g64crc) - g64crc = (uint64)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat)); + g64crc = (uint64_t)(_txUtil->checksumTx(texture, srcwidth, srcheight, srcformat)); DBG_INFO(80, "filter: crc:%08X %08X %d x %d gfmt:%x\n", (uint32)(g64crc >> 32), (uint32)(g64crc & 0xffffffff), srcwidth, srcheight, srcformat); @@ -208,25 +199,25 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint */ if ((srcwidth >= 4 && srcheight >= 4) && ((_options & (FILTER_MASK | ENHANCEMENT_MASK | COMPRESSION_MASK)) || - (srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) { + (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)))) { #if !_16BPP_HACK /* convert textures to a format that the compressor accepts (ARGB8888) */ if (_options & COMPRESSION_MASK) { #endif - if (srcformat != GR_TEXFMT_ARGB_8888) { - if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GR_TEXFMT_ARGB_8888)) { + if (srcformat != GFX_TEXFMT_ARGB_8888) { + if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, srcformat, GFX_TEXFMT_ARGB_8888)) { DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); return 0; } texture = tmptex; - destformat = GR_TEXFMT_ARGB_8888; + destformat = GFX_TEXFMT_ARGB_8888; } #if !_16BPP_HACK } #endif switch (destformat) { - case GR_TEXFMT_ARGB_8888: + case GFX_TEXFMT_ARGB_8888: /* * prepare texture enhancements (x2, x4 scalers) @@ -293,8 +284,8 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint /* * texture compression */ - /* ignored if we only have texture compression option on. - * only done when texture enhancer is used. see constructor. */ + /* ignored if we only have texture compression option on. + * only done when texture enhancer is used. see constructor. */ if ((_options & COMPRESSION_MASK) && (srcwidth >= 64 && srcheight >= 64) /* Texture compression is not suitable for low pixel coarse detail * textures. The assumption here is that textures larger than 64x64 @@ -304,16 +295,16 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint * reasonable if decisions are made based on fourier-transform * spectrum or RMS error. */ - ) { + ) { int compressionType = _options & COMPRESSION_MASK; int tmpwidth, tmpheight; uint16 tmpformat; /* XXX: textures that use 8bit alpha channel look bad with the current * fxt1 library, so we substitute it with dxtn for now. afaik all gfx * cards that support fxt1 also support dxtn. (3dfx and Intel) */ - if ((destformat == GR_TEXFMT_ALPHA_INTENSITY_88) || - (destformat == GR_TEXFMT_ARGB_8888) || - (destformat == GR_TEXFMT_ALPHA_8)) { + if ((destformat == GFX_TEXFMT_ALPHA_INTENSITY_88) || + (destformat == GFX_TEXFMT_ARGB_8888) || + (destformat == GFX_TEXFMT_ALPHA_8)) { compressionType = S3TC_COMPRESSION; } tmptex = (texture == _tex1) ? _tex2 : _tex1; @@ -331,11 +322,11 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint /* * texture (re)conversions */ - if (destformat == GR_TEXFMT_ARGB_8888) { - if (srcformat == GR_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GR_TEXFMT_ARGB_4444; - if (srcformat != GR_TEXFMT_ARGB_8888) { + if (destformat == GFX_TEXFMT_ARGB_8888) { + if (srcformat == GFX_TEXFMT_ARGB_8888 && (_maxbpp < 32 || _options & FORCE16BPP_TEX)) srcformat = GFX_TEXFMT_ARGB_4444; + if (srcformat != GFX_TEXFMT_ARGB_8888) { tmptex = (texture == _tex1) ? _tex2 : _tex1; - if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GR_TEXFMT_ARGB_8888, srcformat)) { + if (!_txQuantize->quantize(texture, tmptex, srcwidth, srcheight, GFX_TEXFMT_ARGB_8888, srcformat)) { DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", srcformat); return 0; } @@ -346,7 +337,7 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint break; #if !_16BPP_HACK - case GR_TEXFMT_ARGB_4444: + case GFX_TEXFMT_ARGB_4444: int scale_shift = 0; tmptex = (texture == _tex1) ? _tex2 : _tex1; @@ -374,25 +365,25 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint } break; case LQ2X_ENHANCEMENT: - if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { + if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { lq2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); scale_shift = 1; } break; case LQ2XS_ENHANCEMENT: - if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { + if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { lq2xS_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); scale_shift = 1; } break; case X2SAI_ENHANCEMENT: - if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { + if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { Super2xSaI_4444((uint16*)texture, (uint16*)tmptex, srcwidth, srcheight, srcwidth); scale_shift = 1; } break; case X2_ENHANCEMENT: - if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { + if (srcwidth <= (_maxwidth >> 1) && srcheight <= (_maxheight >> 1)) { Texture2x_16((uint8*)texture, srcwidth * 2, (uint8*)tmptex, srcwidth * 2 * 2, srcwidth, srcheight); scale_shift = 1; } @@ -407,18 +398,19 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint tmptex = (texture == _tex1) ? _tex2 : _tex1; SmoothFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SMOOTH_FILTER_MASK)); texture = tmptex; - } else if (_options & SHARP_FILTER_MASK) { + } + else if (_options & SHARP_FILTER_MASK) { tmptex = (texture == _tex1) ? _tex2 : _tex1; SharpFilter_4444((uint16*)texture, srcwidth, srcheight, (uint16*)tmptex, (_options & SHARP_FILTER_MASK)); texture = tmptex; } break; - case GR_TEXFMT_ARGB_1555: + case GFX_TEXFMT_ARGB_1555: break; - case GR_TEXFMT_RGB_565: + case GFX_TEXFMT_RGB_565: break; - case GR_TEXFMT_ALPHA_8: + case GFX_TEXFMT_ALPHA_8: break; #endif /* _16BPP_HACK */ } @@ -442,8 +434,8 @@ TxFilter::filter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, uint return 1; } -boolean -TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info) +bool +TxFilter::hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info) { /* NOTE: Rice CRC32 sometimes return the same value for different textures. * As a workaround, Glide64 CRC32 is used for the key for NON-hires @@ -501,8 +493,8 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i * NOTE: the pre-converted palette from Glide64 is in RGBA5551 format. * A comp comes before RGB comp. */ - if (palette && info->format == GR_TEXFMT_P_8) { - DBG_INFO(80, "found GR_TEXFMT_P_8 format. Need conversion!!\n"); + if (palette && info->format == GFX_TEXFMT_P_8) { + DBG_INFO(80, "found GFX_TEXFMT_P_8 format. Need conversion!!\n"); int width = info->width; int height = info->height; @@ -514,31 +506,31 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i /* use palette and convert to 16bit format */ _txQuantize->P8_16BPP((uint32*)texture, (uint32*)tmptex, info->width, info->height, (uint32*)palette); texture = tmptex; - format = GR_TEXFMT_ARGB_1555; + format = GFX_TEXFMT_ARGB_1555; #if 1 /* XXX: compressed if memory cache compression is ON */ if (_options & COMPRESSION_MASK) { tmptex = (texture == _tex1) ? _tex2 : _tex1; - if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GR_TEXFMT_ARGB_8888)) { + if (_txQuantize->quantize(texture, tmptex, info->width, info->height, format, GFX_TEXFMT_ARGB_8888)) { texture = tmptex; - format = GR_TEXFMT_ARGB_8888; + format = GFX_TEXFMT_ARGB_8888; } - if (format == GR_TEXFMT_ARGB_8888) { + if (format == GFX_TEXFMT_ARGB_8888) { tmptex = (texture == _tex1) ? _tex2 : _tex1; if (_txQuantize->compress(texture, tmptex, - info->width, info->height, GR_TEXFMT_ARGB_1555, + info->width, info->height, GFX_TEXFMT_ARGB_1555, &width, &height, &format, _options & COMPRESSION_MASK)) { texture = tmptex; } else { - /*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GR_TEXFMT_ARGB_8888, GR_TEXFMT_ARGB_1555)) { + /*if (!_txQuantize->quantize(texture, tmptex, info->width, info->height, GFX_TEXFMT_ARGB_8888, GFX_TEXFMT_ARGB_1555)) { DBG_INFO(80, "Error: unsupported format! gfmt:%x\n", format); return 0; }*/ texture = tmptex; - format = GR_TEXFMT_ARGB_1555; + format = GFX_TEXFMT_ARGB_1555; } } } @@ -557,7 +549,7 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i /* XXX: add to hires texture cache!!! */ _txHiResCache->add(r_crc64, info); - DBG_INFO(80, "GR_TEXFMT_P_8 loaded as gfmt:%x!\n", format); + DBG_INFO(80, "GFX_TEXFMT_P_8 loaded as gfmt:%x!\n", format); } return 1; @@ -580,7 +572,7 @@ TxFilter::hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *i return 0; } -uint64 +uint64_t TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) { if (_options & (HIRESTEXTURES_MASK | DUMP_TEX)) @@ -590,8 +582,8 @@ TxFilter::checksum64(uint8 *src, int width, int height, int size, int rowStride, return 0; } -boolean -TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64) +bool +TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64) { if (!_initialized) { @@ -605,7 +597,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf DBG_INFO(80, "hirestex: r_crc64:%08X %08X\n", (uint32)(r_crc64 >> 32), (uint32)(r_crc64 & 0xffffffff)); - if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GR_TEXFMT_ARGB_8888)) + if (!_txQuantize->quantize(src, _tex1, rowStridePixel, height, (gfmt & 0x00ff), GFX_TEXFMT_ARGB_8888)) { return 0; } @@ -657,7 +649,7 @@ TxFilter::dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gf return 0; } -boolean TxFilter::reloadhirestex() +bool TxFilter::reloadhirestex() { DBG_INFO(80, "Reload hires textures from texture pack.\n"); diff --git a/Source/Project64-video/TextureEnhancer/TxFilter.h b/Source/Project64-video/TextureEnhancer/TxFilter.h index b106c05f2..94feec3a0 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilter.h +++ b/Source/Project64-video/TextureEnhancer/TxFilter.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXFILTER_H__ #define __TXFILTER_H__ @@ -35,47 +26,47 @@ class TxFilter { private: - int _numcore; + int _numcore; - uint8 *_tex1; - uint8 *_tex2; - int _maxwidth; - int _maxheight; - int _maxbpp; - int _options; - int _cacheSize; - std::string _ident; - std::string _path; - TxQuantize *_txQuantize; - TxTexCache *_txTexCache; - TxHiResCache *_txHiResCache; - TxUtil *_txUtil; - TxImage *_txImage; - boolean _initialized; - void clear(); + uint8 *_tex1; + uint8 *_tex2; + int _maxwidth; + int _maxheight; + int _maxbpp; + int _options; + int _cacheSize; + std::string _ident; + std::string _path; + TxQuantize *_txQuantize; + TxTexCache *_txTexCache; + TxHiResCache *_txHiResCache; + TxUtil *_txUtil; + TxImage *_txImage; + bool _initialized; + void clear(); public: - ~TxFilter(); - TxFilter(int maxwidth, - int maxheight, - int maxbpp, - int options, - int cachesize, - const char *path, - const char *ident, - dispInfoFuncExt callback); - boolean filter(uint8 *src, - int srcwidth, - int srcheight, - uint16 srcformat, - uint64 g64crc, /* glide64 crc, 64bit for future use */ - GHQTexInfo *info); - boolean hirestex(uint64 g64crc, /* glide64 crc, 64bit for future use */ - uint64 r_crc64, /* checksum hi:palette low:texture */ - uint16 *palette, - GHQTexInfo *info); - uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); - boolean dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64); - boolean reloadhirestex(); + ~TxFilter(); + TxFilter(int maxwidth, + int maxheight, + int maxbpp, + int options, + int cachesize, + const char *path, + const char *ident, + dispInfoFuncExt callback); + bool filter(uint8 *src, + int srcwidth, + int srcheight, + uint16 srcformat, + uint64_t g64crc, /* glide64 crc, 64bit for future use */ + GHQTexInfo *info); + bool hirestex(uint64_t g64crc, /* glide64 crc, 64bit for future use */ + uint64_t r_crc64, /* checksum hi:palette low:texture */ + uint16 *palette, + GHQTexInfo *info); + uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); + bool dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64); + bool reloadhirestex(); }; #endif /* __TXFILTER_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp b/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp index 0c72f4476..e78d965b0 100644 --- a/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp +++ b/Source/Project64-video/TextureEnhancer/TxFilterExport.cpp @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef WIN32 #pragma warning(disable: 4786) @@ -30,76 +21,76 @@ TxFilter *txFilter = NULL; #ifdef __cplusplus -extern "C"{ +extern "C" { #endif -TAPI boolean TAPIENTRY -txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize, - const char *path, const char * ident, - dispInfoFuncExt callback) -{ - if (txFilter) return 0; + TAPI bool TAPIENTRY + txfilter_init(int maxwidth, int maxheight, int maxbpp, int options, int cachesize, + const char *path, const char * ident, + dispInfoFuncExt callback) + { + if (txFilter) return 0; - txFilter = new TxFilter(maxwidth, maxheight, maxbpp, options, cachesize, - path, ident, callback); + txFilter = new TxFilter(maxwidth, maxheight, maxbpp, options, cachesize, + path, ident, callback); - return (txFilter ? 1 : 0); -} + return (txFilter ? 1 : 0); + } -void txfilter_shutdown(void) -{ - if (txFilter) delete txFilter; + void txfilter_shutdown(void) + { + if (txFilter) delete txFilter; - txFilter = NULL; -} + txFilter = NULL; + } -TAPI boolean TAPIENTRY -txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, - uint64 g64crc, GHQTexInfo *info) -{ - if (txFilter) - return txFilter->filter(src, srcwidth, srcheight, srcformat, - g64crc, info); + TAPI bool TAPIENTRY + txfilter(uint8 *src, int srcwidth, int srcheight, uint16 srcformat, + uint64_t g64crc, GHQTexInfo *info) + { + if (txFilter) + return txFilter->filter(src, srcwidth, srcheight, srcformat, + g64crc, info); - return 0; -} + return 0; + } -TAPI boolean TAPIENTRY -txfilter_hirestex(uint64 g64crc, uint64 r_crc64, uint16 *palette, GHQTexInfo *info) -{ - if (txFilter) - return txFilter->hirestex(g64crc, r_crc64, palette, info); + TAPI bool TAPIENTRY + txfilter_hirestex(uint64_t g64crc, uint64_t r_crc64, uint16 *palette, GHQTexInfo *info) + { + if (txFilter) + return txFilter->hirestex(g64crc, r_crc64, palette, info); - return 0; -} + return 0; + } -TAPI uint64 TAPIENTRY -txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) -{ - if (txFilter) - return txFilter->checksum64(src, width, height, size, rowStride, palette); + TAPI uint64_t TAPIENTRY + txfilter_checksum(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) + { + if (txFilter) + return txFilter->checksum64(src, width, height, size, rowStride, palette); - return 0; -} + return 0; + } -TAPI boolean TAPIENTRY -txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64 r_crc64) -{ - if (txFilter) - return txFilter->dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64); + TAPI bool TAPIENTRY + txfilter_dmptx(uint8 *src, int width, int height, int rowStridePixel, uint16 gfmt, uint16 n64fmt, uint64_t r_crc64) + { + if (txFilter) + return txFilter->dmptx(src, width, height, rowStridePixel, gfmt, n64fmt, r_crc64); - return 0; -} + return 0; + } -TAPI boolean TAPIENTRY -txfilter_reloadhirestex() -{ - if (txFilter) - return txFilter->reloadhirestex(); + TAPI bool TAPIENTRY + txfilter_reloadhirestex() + { + if (txFilter) + return txFilter->reloadhirestex(); - return 0; -} + return 0; + } #ifdef __cplusplus } -#endif +#endif \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp b/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp index 4b390b18b..df3ad5a46 100644 --- a/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxHiResCache.cpp @@ -1,28 +1,17 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* 2007 Gonetz - * Added callback to display hires texture info. */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef _WIN32 #pragma warning(disable: 4786) @@ -32,14 +21,14 @@ * (0:disable, 1:enable) */ #define DUMP_CACHE 1 -/* handle oversized textures by - * 0: minification - * 1: Glide64 style tiling - */ + /* handle oversized textures by + * 0: minification + * 1: Glide64 style tiling + */ #define TEXTURE_TILING 1 -/* use power of 2 texture size - * (0:disable, 1:enable, 2:3dfx) */ + /* use power of 2 texture size + * (0:disable, 1:enable, 2:3dfx) */ #define POW2_TEXTURES 2 #if TEXTURE_TILING @@ -47,13 +36,13 @@ #define POW2_TEXTURES 2 #endif -/* hack to reduce texture footprint to achieve - * better performace on midrange gfx cards. - * (0:disable, 1:enable) */ + /* hack to reduce texture footprint to achieve + * better performace on midrange gfx cards. + * (0:disable, 1:enable) */ #define REDUCE_TEXTURE_FOOTPRINT 0 -/* use aggressive format assumption for quantization - * (0:disable, 1:enable, 2:extreme) */ + /* use aggressive format assumption for quantization + * (0:disable, 1:enable, 2:extreme) */ #define AGGRESSIVE_QUANTIZATION 1 #include "TxHiResCache.h" @@ -62,6 +51,7 @@ #include #include #include +#include #ifdef _WIN32 #include #endif @@ -88,7 +78,7 @@ TxHiResCache::~TxHiResCache() } TxHiResCache::TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, const char *path, const char *ident, dispInfoFuncExt callback) : -TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback) + TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback) { _txImage = new TxImage(); _txQuantize = new TxQuantize(); @@ -129,14 +119,14 @@ TxCache((options & ~GZ_TEXCACHE), 0, path, ident, callback) if (!_haveCache) TxHiResCache::load(0); } -boolean +bool TxHiResCache::empty() { return _cache.empty(); } -boolean -TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */ +bool +TxHiResCache::load(bool replace) /* 0 : reload, 1 : replace partial */ { if (!_path.empty() && !_ident.empty()) { @@ -168,7 +158,7 @@ TxHiResCache::load(boolean replace) /* 0 : reload, 1 : replace partial */ return 0; } -boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) +bool TxHiResCache::loadHiResTextures(const char * dir_path, bool replace) { #ifdef _WIN32 DBG_INFO(80, "-----\n"); @@ -198,12 +188,6 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) { do { - if (KBHIT(0x1B)) - { - _abortLoad = 1; - if (_callback) (*_callback)("Aborted loading hiresolution texture!\n"); - INFO(80, "Error: aborted loading hiresolution texture!\n"); - } if (_abortLoad) break; DBG_INFO(80, "-----\n"); @@ -221,7 +205,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* Rice hi-res textures: begin */ uint32 chksum = 0, fmt = 0, siz = 0, palchksum = 0; - char *pfname = NULL, fname[MAX_PATH]; + char *pfname = NULL, fname[260]; std::string ident; FILE *fp = NULL; @@ -240,7 +224,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* read in Rice's file naming convention */ #define CRCFMTSIZ_LEN 13 #define PALCRC_LEN 9 - wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), MAX_PATH); + wcstombs(fname, stdstr(TextureDir.GetNameExtension()).ToUTF16().c_str(), 260); /* XXX case sensitivity fiasco! * files must use _a, _rgb, _all, _allciByRGBA, _ciByRGBA, _ci * and file extensions must be in lower case letters! */ @@ -294,9 +278,9 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* check if we already have it in hires texture cache */ if (!replace) { - uint64 chksum64 = (uint64)palchksum; + uint64_t chksum64 = (uint64_t)palchksum; chksum64 <<= 32; - chksum64 |= (uint64)chksum; + chksum64 |= (uint64_t)chksum; if (TxCache::is_cached(chksum64)) { #if !DEBUG INFO(80, "-----\n"); @@ -382,7 +366,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) if (tmptex) { /* check if _rgb.* and _a.* have matching size and format. */ if (!tex || width != tmpwidth || height != tmpheight || - format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) { + format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) { #if !DEBUG INFO(80, "-----\n"); INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); @@ -394,7 +378,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) else if (width != tmpwidth || height != tmpheight) { INFO(80, "Error: _rgb.* and _a.* have mismatched width or height!\n"); } - else if (format != GR_TEXFMT_ARGB_8888 || tmpformat != GR_TEXFMT_ARGB_8888) { + else if (format != GFX_TEXFMT_ARGB_8888 || tmpformat != GFX_TEXFMT_ARGB_8888) { INFO(80, "Error: _rgb.* or _a.* not in 32bit color!\n"); } if (tex) free(tex); @@ -421,7 +405,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) uint32 texel = ((uint32*)tmptex)[i]; uint32 acomp = (((texel >> 16) & 0xff) * 6969 + ((texel >> 8) & 0xff) * 23434 + - ((texel)& 0xff) * 2365) / 32768; + ((texel) & 0xff) * 2365) / 32768; ((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff); #endif #if 0 @@ -429,7 +413,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) uint32 texel = ((uint32*)tmptex)[i]; uint32 acomp = (((texel >> 16) & 0xff) * 299 + ((texel >> 8) & 0xff) * 587 + - ((texel)& 0xff) * 114) / 1000; + ((texel) & 0xff) * 114) / 1000; ((uint32*)tex)[i] = (acomp << 24) | (((uint32*)tex)[i] & 0x00ffffff); #endif } @@ -457,58 +441,58 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) * read in _all.png, _all.dds, _allciByRGBA.png, _allciByRGBA.dds * _ciByRGBA.png, _ciByRGBA.dds, _ci.bmp */ - if (pfname == strstr(fname, "_all.png") || - pfname == strstr(fname, "_all.dds") || + if (pfname == strstr(fname, "_all.png") || + pfname == strstr(fname, "_all.dds") || #ifdef _WIN32 - pfname == strstr(fname, "_allcibyrgba.png") || - pfname == strstr(fname, "_allcibyrgba.dds") || - pfname == strstr(fname, "_cibyrgba.png") || - pfname == strstr(fname, "_cibyrgba.dds") || + pfname == strstr(fname, "_allcibyrgba.png") || + pfname == strstr(fname, "_allcibyrgba.dds") || + pfname == strstr(fname, "_cibyrgba.png") || + pfname == strstr(fname, "_cibyrgba.dds") || #else - pfname == strstr(fname, "_allciByRGBA.png") || - pfname == strstr(fname, "_allciByRGBA.dds") || - pfname == strstr(fname, "_ciByRGBA.png") || - pfname == strstr(fname, "_ciByRGBA.dds") || + pfname == strstr(fname, "_allciByRGBA.png") || + pfname == strstr(fname, "_allciByRGBA.dds") || + pfname == strstr(fname, "_ciByRGBA.png") || + pfname == strstr(fname, "_ciByRGBA.dds") || #endif - pfname == strstr(fname, "_ci.bmp")) { - CPath TargetFile(dir_path, fname); - if ((fp = fopen(TargetFile, "rb")) != NULL) { - if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format); - else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format); - else tex = _txImage->readBMP(fp, &width, &height, &format); - fclose(fp); - } - /* XXX: auto-adjustment of dxt dds textures unsupported for now */ - if (tex && strstr(fname, ".dds")) { - const float aspectratio = (width > height) ? (float)width / (float)height : (float)height / (float)width; - if (!(aspectratio == 1.0 || - aspectratio == 2.0 || - aspectratio == 4.0 || - aspectratio == 8.0)) { - free(tex); - tex = NULL; + pfname == strstr(fname, "_ci.bmp")) { + CPath TargetFile(dir_path, fname); + if ((fp = fopen(TargetFile, "rb")) != NULL) { + if (strstr(fname, ".png")) tex = _txImage->readPNG(fp, &width, &height, &format); + else if (strstr(fname, ".dds")) tex = _txImage->readDDS(fp, &width, &height, &format); + else tex = _txImage->readBMP(fp, &width, &height, &format); + fclose(fp); + } + /* XXX: auto-adjustment of dxt dds textures unsupported for now */ + if (tex && strstr(fname, ".dds")) { + const float aspectratio = (width > height) ? (float)width / (float)height : (float)height / (float)width; + if (!(aspectratio == 1.0 || + aspectratio == 2.0 || + aspectratio == 4.0 || + aspectratio == 8.0)) { + free(tex); + tex = NULL; #if !DEBUG - INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "-----\n"); + INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: W:H aspect ratio range not 8:1 - 1:8!\n"); - continue; - } - if (width != _txReSample->nextPow2(width) || - height != _txReSample->nextPow2(height)) { - free(tex); - tex = NULL; + INFO(80, "Error: W:H aspect ratio range not 8:1 - 1:8!\n"); + continue; + } + if (width != _txReSample->nextPow2(width) || + height != _txReSample->nextPow2(height)) { + free(tex); + tex = NULL; #if !DEBUG - INFO(80, "-----\n"); - INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); - INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); + INFO(80, "-----\n"); + INFO(80, "path: %ls\n", stdstr(dir_path).ToUTF16().c_str()); + INFO(80, "file: %ls\n", TextureDir.GetNameExtension().ToUTF16().c_str()); #endif - INFO(80, "Error: not power of 2 size!\n"); - continue; - } - } - } + INFO(80, "Error: not power of 2 size!\n"); + continue; + } + } + } /* if we do not have a texture at this point we are screwed */ if (!tex) { @@ -523,11 +507,11 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) DBG_INFO(80, "read in as %d x %d gfmt:%x\n", tmpwidth, tmpheight, tmpformat); /* check if size and format are OK */ - if (!(format == GR_TEXFMT_ARGB_8888 || - format == GR_TEXFMT_P_8 || - format == GR_TEXFMT_ARGB_CMP_DXT1 || - format == GR_TEXFMT_ARGB_CMP_DXT3 || - format == GR_TEXFMT_ARGB_CMP_DXT5) || + if (!(format == GFX_TEXFMT_ARGB_8888 || + format == GFX_TEXFMT_P_8 || + format == GFX_TEXFMT_ARGB_CMP_DXT1 || + format == GFX_TEXFMT_ARGB_CMP_DXT3 || + format == GFX_TEXFMT_ARGB_CMP_DXT5) || (width * height) < 4) { /* TxQuantize requirement: width * height must be 4 or larger. */ free(tex); tex = NULL; @@ -541,11 +525,11 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) } /* analyze and determine best format to quantize */ - if (format == GR_TEXFMT_ARGB_8888) { + if (format == GFX_TEXFMT_ARGB_8888) { int i; int alphabits = 0; int fullalpha = 0; - boolean intensity = 1; + bool intensity = 1; if (!(_options & LET_TEXARTISTS_FLY)) { /* HACK ALERT! */ @@ -634,7 +618,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) if (intensity) { int rcomp = (texel >> 16) & 0xff; int gcomp = (texel >> 8) & 0xff; - int bcomp = (texel)& 0xff; + int bcomp = (texel) & 0xff; #if AGGRESSIVE_QUANTIZATION if (abs(rcomp - gcomp) > 8 || abs(rcomp - bcomp) > 8 || abs(gcomp - bcomp) > 8) intensity = 0; #else @@ -649,33 +633,33 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) #if !REDUCE_TEXTURE_FOOTPRINT if (_maxbpp < 32 || _options & (FORCE16BPP_HIRESTEX | COMPRESSION_MASK)) { #endif - if (alphabits == 0) destformat = GR_TEXFMT_RGB_565; - else if (alphabits == 1) destformat = GR_TEXFMT_ARGB_1555; - else destformat = GR_TEXFMT_ARGB_8888; + if (alphabits == 0) destformat = GFX_TEXFMT_RGB_565; + else if (alphabits == 1) destformat = GFX_TEXFMT_ARGB_1555; + else destformat = GFX_TEXFMT_ARGB_8888; #if !REDUCE_TEXTURE_FOOTPRINT } else { - destformat = GR_TEXFMT_ARGB_8888; + destformat = GFX_TEXFMT_ARGB_8888; } #endif if (fmt == 4 && alphabits == 0) { - destformat = GR_TEXFMT_ARGB_8888; + destformat = GFX_TEXFMT_ARGB_8888; /* Rice I format; I = (R + G + B) / 3 */ for (i = 0; i < height * width; i++) { uint32 texel = ((uint32*)tex)[i]; uint32 icomp = (((texel >> 16) & 0xff) + ((texel >> 8) & 0xff) + - ((texel)& 0xff)) / 3; + ((texel) & 0xff)) / 3; ((uint32*)tex)[i] = (icomp << 24) | (texel & 0x00ffffff); } } if (intensity) { if (alphabits == 0) { - if (fmt == 4) destformat = GR_TEXFMT_ALPHA_8; - else destformat = GR_TEXFMT_INTENSITY_8; + if (fmt == 4) destformat = GFX_TEXFMT_ALPHA_8; + else destformat = GFX_TEXFMT_INTENSITY_8; } else { - destformat = GR_TEXFMT_ALPHA_INTENSITY_88; + destformat = GFX_TEXFMT_ALPHA_INTENSITY_88; } } @@ -684,8 +668,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* * Rice hi-res textures: end */ - /* XXX: only ARGB8888 for now. comeback to this later... */ - if (format == GR_TEXFMT_ARGB_8888) { + /* XXX: only ARGB8888 for now. comeback to this later... */ + if (format == GFX_TEXFMT_ARGB_8888) { #if TEXTURE_TILING /* Glide64 style texture tiling */ @@ -695,136 +679,136 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* NOTE: we skip this for palette textures that need minification * becasue it will look ugly. */ - /* minification */ - { - int ratio = 1; + /* minification */ + { + int ratio = 1; - /* minification to enable glide64 style texture tiling */ - /* determine the minification ratio to tile the texture into 256x256 size */ - if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { - DBG_INFO(80, "determine minification ratio to tile\n"); - tmpwidth = width; - tmpheight = height; - if (height > 256) { - ratio = ((height - 1) >> 8) + 1; - tmpwidth = width / ratio; - tmpheight = height / ratio; - DBG_INFO(80, "height > 256, minification ratio:%d %d x %d -> %d x %d\n", - ratio, width, height, tmpwidth, tmpheight); - } - if (tmpwidth > 256 && (((tmpwidth - 1) >> 8) + 1) * tmpheight > 256) { - ratio *= ((((((tmpwidth - 1) >> 8) + 1) * tmpheight) - 1) >> 8) + 1; - DBG_INFO(80, "width > 256, minification ratio:%d %d x %d -> %d x %d\n", - ratio, width, height, width / ratio, height / ratio); - } - } - else { - /* normal minification to fit max texture size */ - if (width > _maxwidth || height > _maxheight) { - DBG_INFO(80, "determine minification ratio to fit max texture size\n"); - tmpwidth = width; - tmpheight = height; - while (tmpwidth > _maxwidth) { - tmpheight >>= 1; - tmpwidth >>= 1; - ratio <<= 1; - } - while (tmpheight > _maxheight) { - tmpheight >>= 1; - tmpwidth >>= 1; - ratio <<= 1; - } - DBG_INFO(80, "minification ratio:%d %d x %d -> %d x %d\n", - ratio, width, height, tmpwidth, tmpheight); - } - } + /* minification to enable glide64 style texture tiling */ + /* determine the minification ratio to tile the texture into 256x256 size */ + if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { + DBG_INFO(80, "determine minification ratio to tile\n"); + tmpwidth = width; + tmpheight = height; + if (height > 256) { + ratio = ((height - 1) >> 8) + 1; + tmpwidth = width / ratio; + tmpheight = height / ratio; + DBG_INFO(80, "height > 256, minification ratio:%d %d x %d -> %d x %d\n", + ratio, width, height, tmpwidth, tmpheight); + } + if (tmpwidth > 256 && (((tmpwidth - 1) >> 8) + 1) * tmpheight > 256) { + ratio *= ((((((tmpwidth - 1) >> 8) + 1) * tmpheight) - 1) >> 8) + 1; + DBG_INFO(80, "width > 256, minification ratio:%d %d x %d -> %d x %d\n", + ratio, width, height, width / ratio, height / ratio); + } + } + else { + /* normal minification to fit max texture size */ + if (width > _maxwidth || height > _maxheight) { + DBG_INFO(80, "determine minification ratio to fit max texture size\n"); + tmpwidth = width; + tmpheight = height; + while (tmpwidth > _maxwidth) { + tmpheight >>= 1; + tmpwidth >>= 1; + ratio <<= 1; + } + while (tmpheight > _maxheight) { + tmpheight >>= 1; + tmpwidth >>= 1; + ratio <<= 1; + } + DBG_INFO(80, "minification ratio:%d %d x %d -> %d x %d\n", + ratio, width, height, tmpwidth, tmpheight); + } + } - if (ratio > 1) { - if (!_txReSample->minify(&tex, &width, &height, ratio)) { - free(tex); - tex = NULL; - DBG_INFO(80, "Error: minification failed!\n"); - continue; - } - } - } + if (ratio > 1) { + if (!_txReSample->minify(&tex, &width, &height, ratio)) { + free(tex); + tex = NULL; + DBG_INFO(80, "Error: minification failed!\n"); + continue; + } + } + } - /* tiling */ - if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { - boolean usetile = 0; + /* tiling */ + if ((_options & TILE_HIRESTEX) && _maxwidth >= 256 && _maxheight >= 256) { + bool usetile = 0; - /* to tile or not to tile, that is the question */ - if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) { - if (width > _maxwidth) usetile = 1; - else { - /* tile if the tiled texture memory footprint is smaller */ - int tilewidth = 256; - int tileheight = _txReSample->nextPow2((((width - 1) >> 8) + 1) * height); - tmpwidth = width; - tmpheight = height; + /* to tile or not to tile, that is the question */ + if (width > 256 && height <= 128 && (((width - 1) >> 8) + 1) * height <= 256) { + if (width > _maxwidth) usetile = 1; + else { + /* tile if the tiled texture memory footprint is smaller */ + int tilewidth = 256; + int tileheight = _txReSample->nextPow2((((width - 1) >> 8) + 1) * height); + tmpwidth = width; + tmpheight = height; - /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ - if (tilewidth > (tileheight << 3)) tileheight = tilewidth >> 3; + /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ + if (tilewidth > (tileheight << 3)) tileheight = tilewidth >> 3; - /* HACKALERT: see TxReSample::pow2(); */ - if (tmpwidth > 64) tmpwidth -= 4; - else if (tmpwidth > 16) tmpwidth -= 2; - else if (tmpwidth > 4) tmpwidth -= 1; + /* HACKALERT: see TxReSample::pow2(); */ + if (tmpwidth > 64) tmpwidth -= 4; + else if (tmpwidth > 16) tmpwidth -= 2; + else if (tmpwidth > 4) tmpwidth -= 1; - if (tmpheight > 64) tmpheight -= 4; - else if (tmpheight > 16) tmpheight -= 2; - else if (tmpheight > 4) tmpheight -= 1; + if (tmpheight > 64) tmpheight -= 4; + else if (tmpheight > 16) tmpheight -= 2; + else if (tmpheight > 4) tmpheight -= 1; - tmpwidth = _txReSample->nextPow2(tmpwidth); - tmpheight = _txReSample->nextPow2(tmpheight); + tmpwidth = _txReSample->nextPow2(tmpwidth); + tmpheight = _txReSample->nextPow2(tmpheight); - /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ - if (tmpwidth > tmpheight) { - if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3; - } - else { - if (tmpheight > (tmpwidth << 3)) tmpwidth = tmpheight >> 3; - } + /* 3dfx Glide3 tmpheight, W:H aspect ratio range (8:1 - 1:8) */ + if (tmpwidth > tmpheight) { + if (tmpwidth > (tmpheight << 3)) tmpheight = tmpwidth >> 3; + } + else { + if (tmpheight > (tmpwidth << 3)) tmpwidth = tmpheight >> 3; + } - usetile = (tilewidth * tileheight < tmpwidth * tmpheight); - } - } + usetile = (tilewidth * tileheight < tmpwidth * tmpheight); + } + } - /* tile it! do the actual tiling into 256x256 size */ - if (usetile) { - DBG_INFO(80, "Glide64 style texture tiling\n"); + /* tile it! do the actual tiling into 256x256 size */ + if (usetile) { + DBG_INFO(80, "Glide64 style texture tiling\n"); - int x, y, z, ratio, offset; - offset = 0; - ratio = ((width - 1) >> 8) + 1; - tmptex = (uint8 *)malloc(_txUtil->sizeofTx(256, height * ratio, format)); - if (tmptex) { - for (x = 0; x < ratio; x++) { - for (y = 0; y < height; y++) { - if (x < ratio - 1) { - memcpy(&tmptex[offset << 2], &tex[(x * 256 + y * width) << 2], 256 << 2); - } - else { - for (z = 0; z < width - 256 * (ratio - 1); z++) { - ((uint32*)tmptex)[offset + z] = ((uint32*)tex)[x * 256 + y * width + z]; - } - for (; z < 256; z++) { - ((uint32*)tmptex)[offset + z] = ((uint32*)tmptex)[offset + z - 1]; - } - } - offset += 256; - } - } - free(tex); - tex = tmptex; - untiled_width = width; - untiled_height = height; - width = 256; - height *= ratio; - DBG_INFO(80, "Tiled: %d x %d -> %d x %d\n", untiled_width, untiled_height, width, height); - } - } - } + int x, y, z, ratio, offset; + offset = 0; + ratio = ((width - 1) >> 8) + 1; + tmptex = (uint8 *)malloc(_txUtil->sizeofTx(256, height * ratio, format)); + if (tmptex) { + for (x = 0; x < ratio; x++) { + for (y = 0; y < height; y++) { + if (x < ratio - 1) { + memcpy(&tmptex[offset << 2], &tex[(x * 256 + y * width) << 2], 256 << 2); + } + else { + for (z = 0; z < width - 256 * (ratio - 1); z++) { + ((uint32*)tmptex)[offset + z] = ((uint32*)tex)[x * 256 + y * width + z]; + } + for (; z < 256; z++) { + ((uint32*)tmptex)[offset + z] = ((uint32*)tmptex)[offset + z - 1]; + } + } + offset += 256; + } + } + free(tex); + tex = tmptex; + untiled_width = width; + untiled_height = height; + width = 256; + height *= ratio; + DBG_INFO(80, "Tiled: %d x %d -> %d x %d\n", untiled_width, untiled_height, width, height); + } + } + } #else /* TEXTURE_TILING */ @@ -833,7 +817,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) int ratio = 1; if (width / _maxwidth > height / _maxheight) { ratio = (int)ceil((double)width / _maxwidth); - } else { + } + else { ratio = (int)ceil((double)height / _maxheight); } if (!_txReSample->minify(&tex, &width, &height, ratio)) { @@ -858,7 +843,7 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) * * NOTE: texture size must be checked before expanding to pow2 size. */ - ) { + ) { int dataSize = 0; int compressionType = _options & COMPRESSION_MASK; @@ -880,40 +865,40 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) switch (_options & COMPRESSION_MASK) { case S3TC_COMPRESSION: switch (destformat) { - case GR_TEXFMT_ARGB_8888: + case GFX_TEXFMT_ARGB_8888: #if GLIDE64_DXTN - case GR_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */ + case GFX_TEXFMT_ARGB_1555: /* for ARGB1555 use DXT5 instead of DXT1 */ #endif - case GR_TEXFMT_ALPHA_INTENSITY_88: + case GFX_TEXFMT_ALPHA_INTENSITY_88: dataSize = width * height; break; #if !GLIDE64_DXTN - case GR_TEXFMT_ARGB_1555: + case GFX_TEXFMT_ARGB_1555: #endif - case GR_TEXFMT_RGB_565: - case GR_TEXFMT_INTENSITY_8: + case GFX_TEXFMT_RGB_565: + case GFX_TEXFMT_INTENSITY_8: dataSize = (width * height) >> 1; break; - case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ + case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ ; } break; case FXT1_COMPRESSION: switch (destformat) { - case GR_TEXFMT_ARGB_1555: - case GR_TEXFMT_RGB_565: - case GR_TEXFMT_INTENSITY_8: + case GFX_TEXFMT_ARGB_1555: + case GFX_TEXFMT_RGB_565: + case GFX_TEXFMT_INTENSITY_8: dataSize = (width * height) >> 1; break; /* XXX: textures that use 8bit alpha channel look bad with the current * fxt1 library, so we substitute it with dxtn for now. afaik all gfx * cards that support fxt1 also support dxtn. (3dfx and Intel) */ - case GR_TEXFMT_ALPHA_INTENSITY_88: - case GR_TEXFMT_ARGB_8888: + case GFX_TEXFMT_ALPHA_INTENSITY_88: + case GFX_TEXFMT_ARGB_8888: compressionType = S3TC_COMPRESSION; dataSize = width * height; break; - case GR_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ + case GFX_TEXFMT_ALPHA_8: /* no size benefit with dxtn */ ; } } @@ -922,8 +907,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) #if 0 /* TEST: dither before compression for better results with gradients */ tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); if (tmptex) { - if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0)) - _txQuantize->quantize(tmptex, tex, width, height, destformat, GR_TEXFMT_ARGB_8888, 0); + if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0)) + _txQuantize->quantize(tmptex, tex, width, height, destformat, GFX_TEXFMT_ARGB_8888, 0); free(tmptex); } #endif @@ -963,50 +948,50 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) } /* quantize */ - { - tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); - if (tmptex) { - switch (destformat) { - case GR_TEXFMT_ARGB_8888: - case GR_TEXFMT_ARGB_4444: + { + tmptex = (uint8 *)malloc(_txUtil->sizeofTx(width, height, destformat)); + if (tmptex) { + switch (destformat) { + case GFX_TEXFMT_ARGB_8888: + case GFX_TEXFMT_ARGB_4444: #if !REDUCE_TEXTURE_FOOTPRINT - if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) + if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) #endif - destformat = GR_TEXFMT_ARGB_4444; - break; - case GR_TEXFMT_ARGB_1555: + destformat = GFX_TEXFMT_ARGB_4444; + break; + case GFX_TEXFMT_ARGB_1555: #if !REDUCE_TEXTURE_FOOTPRINT - if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) + if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) #endif - destformat = GR_TEXFMT_ARGB_1555; - break; - case GR_TEXFMT_RGB_565: + destformat = GFX_TEXFMT_ARGB_1555; + break; + case GFX_TEXFMT_RGB_565: #if !REDUCE_TEXTURE_FOOTPRINT - if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) + if (_maxbpp < 32 || _options & FORCE16BPP_HIRESTEX) #endif - destformat = GR_TEXFMT_RGB_565; - break; - case GR_TEXFMT_ALPHA_INTENSITY_88: - case GR_TEXFMT_ALPHA_INTENSITY_44: + destformat = GFX_TEXFMT_RGB_565; + break; + case GFX_TEXFMT_ALPHA_INTENSITY_88: + case GFX_TEXFMT_ALPHA_INTENSITY_44: #if !REDUCE_TEXTURE_FOOTPRINT - destformat = GR_TEXFMT_ALPHA_INTENSITY_88; + destformat = GFX_TEXFMT_ALPHA_INTENSITY_88; #else - destformat = GR_TEXFMT_ALPHA_INTENSITY_44; + destformat = GFX_TEXFMT_ALPHA_INTENSITY_44; #endif - break; - case GR_TEXFMT_ALPHA_8: - destformat = GR_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */ - break; - case GR_TEXFMT_INTENSITY_8: - destformat = GR_TEXFMT_INTENSITY_8; - } - if (_txQuantize->quantize(tex, tmptex, width, height, GR_TEXFMT_ARGB_8888, destformat, 0)) { - format = destformat; - free(tex); - tex = tmptex; - } - } - } + break; + case GFX_TEXFMT_ALPHA_8: + destformat = GFX_TEXFMT_ALPHA_8; /* yes, this is correct. ALPHA_8 instead of INTENSITY_8 */ + break; + case GFX_TEXFMT_INTENSITY_8: + destformat = GFX_TEXFMT_INTENSITY_8; + } + if (_txQuantize->quantize(tex, tmptex, width, height, GFX_TEXFMT_ARGB_8888, destformat, 0)) { + format = destformat; + free(tex); + tex = tmptex; + } + } + } } /* last minute validations */ @@ -1029,9 +1014,9 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) /* load it into hires texture cache. */ { - uint64 chksum64 = (uint64)palchksum; + uint64_t chksum64 = (uint64_t)palchksum; chksum64 <<= 32; - chksum64 |= (uint64)chksum; + chksum64 |= (uint64_t)chksum; GHQTexInfo tmpInfo; memset(&tmpInfo, 0, sizeof(GHQTexInfo)); @@ -1047,7 +1032,8 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) #if TEXTURE_TILING /* Glide64 style texture tiling. */ - if (untiled_width && untiled_height) { + if (untiled_width && untiled_height) + { tmpInfo.tiles = ((untiled_width - 1) >> 8) + 1; tmpInfo.untiled_width = untiled_width; tmpInfo.untiled_height = untiled_height; @@ -1055,17 +1041,20 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) #endif /* remove redundant in cache */ - if (replace && TxCache::del(chksum64)) { + if (replace && TxCache::del(chksum64)) + { DBG_INFO(80, "removed duplicate old cache.\n"); } /* add to cache */ - if (TxCache::add(chksum64, &tmpInfo)) { + if (TxCache::add(chksum64, &tmpInfo)) + { /* Callback to display hires texture info. * Gonetz */ - if (_callback) { - wchar_t tmpbuf[MAX_PATH]; - mbstowcs(tmpbuf, fname, MAX_PATH); + if (_callback) + { + wchar_t tmpbuf[260]; + mbstowcs(tmpbuf, fname, 260); (*_callback)("[%d] total mem:%.2fmb - %ls\n", _cache.size(), (float)_totalSize / 1000000, tmpbuf); } DBG_INFO(80, "texture loaded!\n"); @@ -1076,4 +1065,4 @@ boolean TxHiResCache::loadHiResTextures(const char * dir_path, boolean replace) } #endif return 1; -} +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxHiResCache.h b/Source/Project64-video/TextureEnhancer/TxHiResCache.h index 8c346e250..465ebf4af 100644 --- a/Source/Project64-video/TextureEnhancer/TxHiResCache.h +++ b/Source/Project64-video/TextureEnhancer/TxHiResCache.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXHIRESCACHE_H__ #define __TXHIRESCACHE_H__ @@ -41,19 +32,19 @@ private: int _maxwidth; int _maxheight; int _maxbpp; - boolean _haveCache; - boolean _abortLoad; + bool _haveCache; + bool _abortLoad; TxImage *_txImage; TxQuantize *_txQuantize; TxReSample *_txReSample; - boolean loadHiResTextures(const char * dir_path, boolean replace); + bool loadHiResTextures(const char * dir_path, bool replace); public: ~TxHiResCache(); TxHiResCache(int maxwidth, int maxheight, int maxbpp, int options, const char *path, const char *ident, dispInfoFuncExt callback); - boolean empty(); - boolean load(boolean replace); + bool empty(); + bool load(bool replace); }; #endif /* __TXHIRESCACHE_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxImage.cpp b/Source/Project64-video/TextureEnhancer/TxImage.cpp index 6dc229cab..77af762fc 100644 --- a/Source/Project64-video/TextureEnhancer/TxImage.cpp +++ b/Source/Project64-video/TextureEnhancer/TxImage.cpp @@ -1,801 +1,797 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ /* use power of 2 texture size * (0:disable, 1:enable, 2:3dfx) */ #define POW2_TEXTURES 0 -/* check 8 bytes. use a larger value if needed. */ + /* check 8 bytes. use a larger value if needed. */ #define PNG_CHK_BYTES 8 #include "TxImage.h" #include "TxReSample.h" #include "TxDbg.h" #include +#include -boolean -TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr) +bool TxImage::getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr) { - unsigned char sig[PNG_CHK_BYTES]; + unsigned char sig[PNG_CHK_BYTES]; - /* check for valid file pointer */ - if (!fp) - return 0; + /* check for valid file pointer */ + if (!fp) + return 0; - /* check if file is PNG */ - if (fread(sig, 1, PNG_CHK_BYTES, fp) != PNG_CHK_BYTES) - return 0; + /* check if file is PNG */ + if (fread(sig, 1, PNG_CHK_BYTES, fp) != PNG_CHK_BYTES) + return 0; - if (png_sig_cmp(sig, 0, PNG_CHK_BYTES) != 0) - return 0; + if (png_sig_cmp(sig, 0, PNG_CHK_BYTES) != 0) + return 0; - /* get PNG file info */ - *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (!*png_ptr) - return 0; + /* get PNG file info */ + *png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!*png_ptr) + return 0; - *info_ptr = png_create_info_struct(*png_ptr); - if (!*info_ptr) { - png_destroy_read_struct(png_ptr, NULL, NULL); - return 0; - } + *info_ptr = png_create_info_struct(*png_ptr); + if (!*info_ptr) { + png_destroy_read_struct(png_ptr, NULL, NULL); + return 0; + } - if (setjmp(png_jmpbuf(*png_ptr))) { - DBG_INFO(80, "error reading png!\n"); - png_destroy_read_struct(png_ptr, info_ptr, NULL); - return 0; - } + if (setjmp(png_jmpbuf(*png_ptr))) { + DBG_INFO(80, "error reading png!\n"); + png_destroy_read_struct(png_ptr, info_ptr, NULL); + return 0; + } - png_init_io(*png_ptr, fp); - png_set_sig_bytes(*png_ptr, PNG_CHK_BYTES); - png_read_info(*png_ptr, *info_ptr); + png_init_io(*png_ptr, fp); + png_set_sig_bytes(*png_ptr, PNG_CHK_BYTES); + png_read_info(*png_ptr, *info_ptr); - return 1; + return 1; } uint8* TxImage::readPNG(FILE* fp, int* width, int* height, uint16* format) { - /* NOTE: returned image format is GR_TEXFMT_ARGB_8888 */ + /* NOTE: returned image format is GFX_TEXFMT_ARGB_8888 */ - png_structp png_ptr; - png_infop info_ptr; - uint8 *image = NULL; - int bit_depth, color_type, interlace_type, compression_type, filter_type, - row_bytes, o_width, o_height, num_pas; + png_structp png_ptr; + png_infop info_ptr; + uint8 *image = NULL; + int bit_depth, color_type, interlace_type, compression_type, filter_type, + row_bytes, o_width, o_height, num_pas; - /* initialize */ - *width = 0; - *height = 0; - *format = 0; + /* initialize */ + *width = 0; + *height = 0; + *format = 0; - /* check if we have a valid png file */ - if (!fp) - return NULL; + /* check if we have a valid png file */ + if (!fp) + return NULL; - if (!getPNGInfo(fp, &png_ptr, &info_ptr)) - { - INFO(80, "error reading png file! png image is corrupt.\n"); - return NULL; - } - - png_get_IHDR(png_ptr, info_ptr, - (png_uint_32*)&o_width, (png_uint_32*)&o_height, &bit_depth, &color_type, - &interlace_type, &compression_type, &filter_type); - - DBG_INFO(80, "png format %d x %d bitdepth:%d color:%x interlace:%x compression:%x filter:%x\n", - o_width, o_height, bit_depth, color_type, - interlace_type, compression_type, filter_type); - - /* transformations */ - - /* Rice hi-res textures - * _all.png - * _rgb.png, _a.png - * _ciByRGBA.png - * _allciByRGBA.png - */ - - /* strip if color channel is larger than 8 bits */ - if (bit_depth > 8) { - png_set_strip_16(png_ptr); - bit_depth = 8; - } - -#if 1 - /* These are not really required per Rice format spec, - * but is done just in case someone uses them. - */ - /* convert palette color to rgb color */ - if (color_type == PNG_COLOR_TYPE_PALETTE) { - png_set_palette_to_rgb(png_ptr); - color_type = PNG_COLOR_TYPE_RGB; - } - - /* expand 1,2,4 bit gray scale to 8 bit gray scale */ - if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_expand(png_ptr); - - /* convert gray scale or gray scale + alpha to rgb color */ - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { - png_set_gray_to_rgb(png_ptr); - color_type = PNG_COLOR_TYPE_RGB; - } -#endif - - /* add alpha channel if any */ - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - png_set_tRNS_to_alpha(png_ptr); - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - } - - /* convert rgb to rgba */ - if (color_type == PNG_COLOR_TYPE_RGB) { - png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - } - - /* punt invalid formats */ - if (color_type != PNG_COLOR_TYPE_RGB_ALPHA) { - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - DBG_INFO(80, "Error: not PNG_COLOR_TYPE_RGB_ALPHA format!\n"); - return NULL; - } - - /*png_color_8p sig_bit; - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit);*/ - - /* convert rgba to bgra */ - png_set_bgr(png_ptr); - - /* turn on interlace handling to cope with the weirdness - * of texture authors using interlaced format */ - num_pas = png_set_interlace_handling(png_ptr); - - /* update info structure */ - png_read_update_info(png_ptr, info_ptr); - - /* we only get here if ARGB8888 */ - row_bytes = png_get_rowbytes(png_ptr, info_ptr); - - /* allocate memory to read in image */ - image = (uint8*)malloc(row_bytes * o_height); - - /* read in image */ - if (image) { - int pas, i; - uint8* tmpimage; - - for (pas = 0; pas < num_pas; pas++) { /* deal with interlacing */ - tmpimage = image; - - for (i = 0; i < o_height; i++) { - /* copy row */ - png_read_rows(png_ptr, &tmpimage, NULL, 1); - tmpimage += row_bytes; - } + if (!getPNGInfo(fp, &png_ptr, &info_ptr)) + { + INFO(80, "error reading png file! png image is corrupt.\n"); + return NULL; } - /* read rest of the info structure */ - png_read_end(png_ptr, info_ptr); + png_get_IHDR(png_ptr, info_ptr, + (png_uint_32*)&o_width, (png_uint_32*)&o_height, &bit_depth, &color_type, + &interlace_type, &compression_type, &filter_type); - *width = (row_bytes >> 2); - *height = o_height; - *format = GR_TEXFMT_ARGB_8888; + DBG_INFO(80, "png format %d x %d bitdepth:%d color:%x interlace:%x compression:%x filter:%x\n", + o_width, o_height, bit_depth, color_type, + interlace_type, compression_type, filter_type); -#if POW2_TEXTURES - /* next power of 2 size conversions */ - /* NOTE: I can do this in the above loop for faster operations, but some - * texture packs require a workaround. see HACKALERT in nextPow2(). + /* transformations */ + + /* Rice hi-res textures + * _all.png + * _rgb.png, _a.png + * _ciByRGBA.png + * _allciByRGBA.png */ - TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. - -#if (POW2_TEXTURES == 2) - if (!txReSample->nextPow2(&image, width, height, 32, 1)) { -#else - if (!txReSample->nextPow2(&image, width, height, 32, 0)) { -#endif - if (image) { - free(image); - image = NULL; - } - *width = 0; - *height = 0; - *format = 0; + /* strip if color channel is larger than 8 bits */ + if (bit_depth > 8) { + png_set_strip_16(png_ptr); + bit_depth = 8; } - delete txReSample; +#if 1 + /* These are not really required per Rice format spec, + * but is done just in case someone uses them. + */ + /* convert palette color to rgb color */ + if (color_type == PNG_COLOR_TYPE_PALETTE) { + png_set_palette_to_rgb(png_ptr); + color_type = PNG_COLOR_TYPE_RGB; + } -#endif /* POW2_TEXTURES */ - } + /* expand 1,2,4 bit gray scale to 8 bit gray scale */ + if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) + png_set_expand(png_ptr); - /* clean up */ - png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - -#ifdef DEBUG - if (!image) { - DBG_INFO(80, "Error: failed to load png image!\n"); - } + /* convert gray scale or gray scale + alpha to rgb color */ + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { + png_set_gray_to_rgb(png_ptr); + color_type = PNG_COLOR_TYPE_RGB; + } #endif - return image; + /* add alpha channel if any */ + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { + png_set_tRNS_to_alpha(png_ptr); + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + } + + /* convert rgb to rgba */ + if (color_type == PNG_COLOR_TYPE_RGB) { + png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + } + + /* punt invalid formats */ + if (color_type != PNG_COLOR_TYPE_RGB_ALPHA) { + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + DBG_INFO(80, "Error: not PNG_COLOR_TYPE_RGB_ALPHA format!\n"); + return NULL; + } + + /*png_color_8p sig_bit; + if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) + png_set_shift(png_ptr, sig_bit);*/ + + /* convert rgba to bgra */ + png_set_bgr(png_ptr); + + /* turn on interlace handling to cope with the weirdness + * of texture authors using interlaced format */ + num_pas = png_set_interlace_handling(png_ptr); + + /* update info structure */ + png_read_update_info(png_ptr, info_ptr); + + /* we only get here if ARGB8888 */ + row_bytes = png_get_rowbytes(png_ptr, info_ptr); + + /* allocate memory to read in image */ + image = (uint8*)malloc(row_bytes * o_height); + + /* read in image */ + if (image) { + int pas, i; + uint8* tmpimage; + + for (pas = 0; pas < num_pas; pas++) { /* deal with interlacing */ + tmpimage = image; + + for (i = 0; i < o_height; i++) { + /* copy row */ + png_read_rows(png_ptr, &tmpimage, NULL, 1); + tmpimage += row_bytes; + } + } + + /* read rest of the info structure */ + png_read_end(png_ptr, info_ptr); + + *width = (row_bytes >> 2); + *height = o_height; + *format = GFX_TEXFMT_ARGB_8888; + +#if POW2_TEXTURES + /* next power of 2 size conversions */ + /* NOTE: I can do this in the above loop for faster operations, but some + * texture packs require a workaround. see HACKALERT in nextPow2(). + */ + + TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. + +#if (POW2_TEXTURES == 2) + if (!txReSample->nextPow2(&image, width, height, 32, 1)) { +#else + if (!txReSample->nextPow2(&image, width, height, 32, 0)) { +#endif + if (image) { + free(image); + image = NULL; + } + *width = 0; + *height = 0; + *format = 0; + } + + delete txReSample; + +#endif /* POW2_TEXTURES */ + } + + /* clean up */ + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + +#ifdef DEBUG + if (!image) { + DBG_INFO(80, "Error: failed to load png image!\n"); + } +#endif + + return image; } -boolean +bool TxImage::writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette) { - png_structp png_ptr; - png_infop info_ptr; - png_color_8 sig_bit; - png_colorp palette_ptr; - png_bytep trans_ptr;//, tex_ptr; - int bit_depth, color_type, row_bytes, num_palette; - int i; - //uint16 srcfmt, destfmt; + png_structp png_ptr; + png_infop info_ptr; + png_color_8 sig_bit; + png_colorp palette_ptr; + png_bytep trans_ptr;//, tex_ptr; + int bit_depth, color_type, row_bytes, num_palette; + int i; + //uint16 srcfmt, destfmt; - if (!src || !fp) - return 0; + if (!src || !fp) + return 0; - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL) - return 0; + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png_ptr == NULL) + return 0; - info_ptr = png_create_info_struct(png_ptr); - if (info_ptr == NULL) { - png_destroy_write_struct(&png_ptr, NULL); - return 0; - } + info_ptr = png_create_info_struct(png_ptr); + if (info_ptr == NULL) { + png_destroy_write_struct(&png_ptr, NULL); + return 0; + } + + /*if (setjmp(png_ptr->jmpbuf)) { + png_destroy_write_struct(&png_ptr, &info_ptr); + return 0; + }*/ + + png_init_io(png_ptr, fp); + + /* TODO: images must be converted to RGBA8888 or CI8, + * palettes need to be separated to A and RGB. */ + + /* N64 formats + * Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I + * Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit + * format = (Format << 8 | Size); + */ + + /* each channel is saved in 8bits for consistency */ + switch (format) { + case 0x0002:/* RGBA5551 */ + bit_depth = 8; + sig_bit.red = 5; + sig_bit.green = 5; + sig_bit.blue = 5; + sig_bit.alpha = 1; + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + break; + case 0x0003:/* RGBA8888 */ + case 0x0302:/* IA88 */ + bit_depth = 8; + sig_bit.red = 8; + sig_bit.green = 8; + sig_bit.blue = 8; + sig_bit.alpha = 8; + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + break; + case 0x0300:/* IA31 */ + bit_depth = 8; + sig_bit.red = 3; + sig_bit.green = 3; + sig_bit.blue = 3; + sig_bit.alpha = 1; + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + break; + case 0x0301:/* IA44 */ + bit_depth = 8; + sig_bit.red = 4; + sig_bit.green = 4; + sig_bit.blue = 4; + sig_bit.alpha = 4; + color_type = PNG_COLOR_TYPE_RGB_ALPHA; + break; + case 0x0400:/* I4 */ + bit_depth = 8; + sig_bit.red = 4; + sig_bit.green = 4; + sig_bit.blue = 4; + color_type = PNG_COLOR_TYPE_RGB; + break; + case 0x0401:/* I8 */ + case 0x0402:/* I16 */ + bit_depth = 8; + sig_bit.red = 8; + sig_bit.green = 8; + sig_bit.blue = 8; + color_type = PNG_COLOR_TYPE_RGB; + break; + case 0x0200:/* CI4 */ + bit_depth = 8; + num_palette = 16; + color_type = PNG_COLOR_TYPE_PALETTE; + break; + case 0x0201:/* CI8 */ + bit_depth = 8; + num_palette = 256; + color_type = PNG_COLOR_TYPE_PALETTE; + break; + case 0x0102:/* YUV ? */ + case 0x0103: + default: + /* unsupported format */ + png_destroy_write_struct(&png_ptr, &info_ptr); + return 0; + } + + switch (color_type) { + case PNG_COLOR_TYPE_RGB_ALPHA: + case PNG_COLOR_TYPE_RGB: + //row_bytes = (bit_depth * width) >> 1; + row_bytes = rowStride; + png_set_bgr(png_ptr); + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + break; + case PNG_COLOR_TYPE_PALETTE: + //row_bytes = (bit_depth * width) >> 3; + row_bytes = rowStride; + png_set_PLTE(png_ptr, info_ptr, palette_ptr, num_palette); + png_set_tRNS(png_ptr, info_ptr, trans_ptr, num_palette, 0); + } + + //png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); + + //if (bit_depth == 16) + // png_set_swap(png_ptr); + + //if (bit_depth < 8) + // png_set_packswap(png_ptr); + + png_set_IHDR(png_ptr, info_ptr, width, height, + bit_depth, color_type, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + //png_set_gAMA(png_ptr, info_ptr, 1.0); + + png_write_info(png_ptr, info_ptr); + for (i = 0; i < height; i++) { + png_write_row(png_ptr, (png_bytep)src); + src += row_bytes; + } + png_write_end(png_ptr, info_ptr); - /*if (setjmp(png_ptr->jmpbuf)) { png_destroy_write_struct(&png_ptr, &info_ptr); - return 0; - }*/ - png_init_io(png_ptr, fp); + //if (tex_ptr) delete [] tex_ptr; - /* TODO: images must be converted to RGBA8888 or CI8, - * palettes need to be separated to A and RGB. */ - - /* N64 formats - * Format: 0 - RGBA, 1 - YUV, 2 - CI, 3 - IA, 4 - I - * Size: 0 - 4bit, 1 - 8bit, 2 - 16bit, 3 - 32 bit - * format = (Format << 8 | Size); - */ - - /* each channel is saved in 8bits for consistency */ - switch (format) { - case 0x0002:/* RGBA5551 */ - bit_depth = 8; - sig_bit.red = 5; - sig_bit.green = 5; - sig_bit.blue = 5; - sig_bit.alpha = 1; - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - break; - case 0x0003:/* RGBA8888 */ - case 0x0302:/* IA88 */ - bit_depth = 8; - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - sig_bit.alpha = 8; - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - break; - case 0x0300:/* IA31 */ - bit_depth = 8; - sig_bit.red = 3; - sig_bit.green = 3; - sig_bit.blue = 3; - sig_bit.alpha = 1; - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - break; - case 0x0301:/* IA44 */ - bit_depth = 8; - sig_bit.red = 4; - sig_bit.green = 4; - sig_bit.blue = 4; - sig_bit.alpha = 4; - color_type = PNG_COLOR_TYPE_RGB_ALPHA; - break; - case 0x0400:/* I4 */ - bit_depth = 8; - sig_bit.red = 4; - sig_bit.green = 4; - sig_bit.blue = 4; - color_type = PNG_COLOR_TYPE_RGB; - break; - case 0x0401:/* I8 */ - case 0x0402:/* I16 */ - bit_depth = 8; - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - color_type = PNG_COLOR_TYPE_RGB; - break; - case 0x0200:/* CI4 */ - bit_depth = 8; - num_palette = 16; - color_type = PNG_COLOR_TYPE_PALETTE; - break; - case 0x0201:/* CI8 */ - bit_depth = 8; - num_palette = 256; - color_type = PNG_COLOR_TYPE_PALETTE; - break; - case 0x0102:/* YUV ? */ - case 0x0103: - default: - /* unsupported format */ - png_destroy_write_struct(&png_ptr, &info_ptr); - return 0; - } - - switch (color_type) { - case PNG_COLOR_TYPE_RGB_ALPHA: - case PNG_COLOR_TYPE_RGB: - //row_bytes = (bit_depth * width) >> 1; - row_bytes = rowStride; - png_set_bgr(png_ptr); - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - break; - case PNG_COLOR_TYPE_PALETTE: - //row_bytes = (bit_depth * width) >> 3; - row_bytes = rowStride; - png_set_PLTE(png_ptr, info_ptr, palette_ptr, num_palette); - png_set_tRNS(png_ptr, info_ptr, trans_ptr, num_palette, 0); - } - - //png_set_filter(png_ptr, 0, PNG_ALL_FILTERS); - - //if (bit_depth == 16) - // png_set_swap(png_ptr); - - //if (bit_depth < 8) - // png_set_packswap(png_ptr); - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - //png_set_gAMA(png_ptr, info_ptr, 1.0); - - png_write_info(png_ptr, info_ptr); - for (i = 0; i < height; i++) { - png_write_row(png_ptr, (png_bytep)src); - src += row_bytes; - } - png_write_end(png_ptr, info_ptr); - - png_destroy_write_struct(&png_ptr, &info_ptr); - - //if (tex_ptr) delete [] tex_ptr; - - return 1; + return 1; } -boolean +bool TxImage::getBMPInfo(FILE* fp, BITMAPFILEHEADER* bmp_fhdr, BITMAPINFOHEADER* bmp_ihdr) { - /* - * read in BITMAPFILEHEADER - */ + /* + * read in BITMAPFILEHEADER + */ - /* is this a BMP file? */ - if (fread(&bmp_fhdr->bfType, 2, 1, fp) != 1) - return 0; + /* is this a BMP file? */ + if (fread(&bmp_fhdr->bfType, 2, 1, fp) != 1) + return 0; - if (memcmp(&bmp_fhdr->bfType, "BM", 2) != 0) - return 0; + if (memcmp(&bmp_fhdr->bfType, "BM", 2) != 0) + return 0; - /* get file size */ - if (fread(&bmp_fhdr->bfSize, 4, 1, fp) != 1) - return 0; + /* get file size */ + if (fread(&bmp_fhdr->bfSize, 4, 1, fp) != 1) + return 0; - /* reserved 1 */ - if (fread(&bmp_fhdr->bfReserved1, 2, 1, fp) != 1) - return 0; + /* reserved 1 */ + if (fread(&bmp_fhdr->bfReserved1, 2, 1, fp) != 1) + return 0; - /* reserved 2 */ - if (fread(&bmp_fhdr->bfReserved2, 2, 1, fp) != 1) - return 0; + /* reserved 2 */ + if (fread(&bmp_fhdr->bfReserved2, 2, 1, fp) != 1) + return 0; - /* offset to the image data */ - if (fread(&bmp_fhdr->bfOffBits, 4, 1, fp) != 1) - return 0; + /* offset to the image data */ + if (fread(&bmp_fhdr->bfOffBits, 4, 1, fp) != 1) + return 0; - /* - * read in BITMAPINFOHEADER - */ + /* + * read in BITMAPINFOHEADER + */ - /* size of BITMAPINFOHEADER */ - if (fread(&bmp_ihdr->biSize, 4, 1, fp) != 1) - return 0; + /* size of BITMAPINFOHEADER */ + if (fread(&bmp_ihdr->biSize, 4, 1, fp) != 1) + return 0; - /* is this a Windows BMP? */ - if (bmp_ihdr->biSize != 40) - return 0; + /* is this a Windows BMP? */ + if (bmp_ihdr->biSize != 40) + return 0; - /* width of the bitmap in pixels */ - if (fread(&bmp_ihdr->biWidth, 4, 1, fp) != 1) - return 0; + /* width of the bitmap in pixels */ + if (fread(&bmp_ihdr->biWidth, 4, 1, fp) != 1) + return 0; - /* height of the bitmap in pixels */ - if (fread(&bmp_ihdr->biHeight, 4, 1, fp) != 1) - return 0; + /* height of the bitmap in pixels */ + if (fread(&bmp_ihdr->biHeight, 4, 1, fp) != 1) + return 0; - /* number of planes (always 1) */ - if (fread(&bmp_ihdr->biPlanes, 2, 1, fp) != 1) - return 0; + /* number of planes (always 1) */ + if (fread(&bmp_ihdr->biPlanes, 2, 1, fp) != 1) + return 0; - /* number of bits-per-pixel. (1, 4, 8, 16, 24, 32) */ - if (fread(&bmp_ihdr->biBitCount, 2, 1, fp) != 1) - return 0; + /* number of bits-per-pixel. (1, 4, 8, 16, 24, 32) */ + if (fread(&bmp_ihdr->biBitCount, 2, 1, fp) != 1) + return 0; - /* compression for a compressed bottom-up bitmap - * 0 : uncompressed format - * 1 : run-length encoded 4 bpp format - * 2 : run-length encoded 8 bpp format - * 3 : bitfield - */ - if (fread(&bmp_ihdr->biCompression, 4, 1, fp) != 1) - return 0; + /* compression for a compressed bottom-up bitmap + * 0 : uncompressed format + * 1 : run-length encoded 4 bpp format + * 2 : run-length encoded 8 bpp format + * 3 : bitfield + */ + if (fread(&bmp_ihdr->biCompression, 4, 1, fp) != 1) + return 0; - /* size of the image in bytes */ - if (fread(&bmp_ihdr->biSizeImage, 4, 1, fp) != 1) - return 0; + /* size of the image in bytes */ + if (fread(&bmp_ihdr->biSizeImage, 4, 1, fp) != 1) + return 0; - /* horizontal resolution in pixels-per-meter */ - if (fread(&bmp_ihdr->biXPelsPerMeter, 4, 1, fp) != 1) - return 0; + /* horizontal resolution in pixels-per-meter */ + if (fread(&bmp_ihdr->biXPelsPerMeter, 4, 1, fp) != 1) + return 0; - /* vertical resolution in pixels-per-meter */ - if (fread(&bmp_ihdr->biYPelsPerMeter, 4, 1, fp) != 1) - return 0; + /* vertical resolution in pixels-per-meter */ + if (fread(&bmp_ihdr->biYPelsPerMeter, 4, 1, fp) != 1) + return 0; - /* number of color indexes in the color table that are actually used */ - if (fread(&bmp_ihdr->biClrUsed, 4, 1, fp) != 1) - return 0; + /* number of color indexes in the color table that are actually used */ + if (fread(&bmp_ihdr->biClrUsed, 4, 1, fp) != 1) + return 0; - /* the number of color indexes that are required for displaying */ - if (fread(&bmp_ihdr->biClrImportant, 4, 1, fp) != 1) - return 0; + /* the number of color indexes that are required for displaying */ + if (fread(&bmp_ihdr->biClrImportant, 4, 1, fp) != 1) + return 0; - return 1; + return 1; } uint8* TxImage::readBMP(FILE* fp, int* width, int* height, uint16* format) { - /* NOTE: returned image format; - * 4, 8bit palette bmp -> GR_TEXFMT_P_8 - * 24, 32bit bmp -> GR_TEXFMT_ARGB_8888 - */ + /* NOTE: returned image format; + * 4, 8bit palette bmp -> GFX_TEXFMT_P_8 + * 24, 32bit bmp -> GFX_TEXFMT_ARGB_8888 + */ - uint8 *image = NULL; - uint8 *image_row = NULL; - uint8 *tmpimage = NULL; - unsigned int row_bytes, pos; - int i, j; - /* Windows Bitmap */ - BITMAPFILEHEADER bmp_fhdr; - BITMAPINFOHEADER bmp_ihdr; + uint8 *image = NULL; + uint8 *image_row = NULL; + uint8 *tmpimage = NULL; + unsigned int row_bytes, pos; + int i, j; + /* Windows Bitmap */ + BITMAPFILEHEADER bmp_fhdr; + BITMAPINFOHEADER bmp_ihdr; - /* initialize */ - *width = 0; - *height = 0; - *format = 0; + /* initialize */ + *width = 0; + *height = 0; + *format = 0; - /* check if we have a valid bmp file */ - if (!fp) - return NULL; + /* check if we have a valid bmp file */ + if (!fp) + return NULL; - if (!getBMPInfo(fp, &bmp_fhdr, &bmp_ihdr)) { - INFO(80, "error reading bitmap file! bitmap image is corrupt.\n"); - return NULL; - } - - DBG_INFO(80, "bmp format %d x %d bitdepth:%d compression:%x offset:%d\n", - bmp_ihdr.biWidth, bmp_ihdr.biHeight, bmp_ihdr.biBitCount, - bmp_ihdr.biCompression, bmp_fhdr.bfOffBits); - - /* rowStride in bytes */ - row_bytes = (bmp_ihdr.biWidth * bmp_ihdr.biBitCount) >> 3; - /* align to 4bytes boundary */ - row_bytes = (row_bytes + 3) & ~3; - - /* Rice hi-res textures */ - if (!(bmp_ihdr.biBitCount == 8 || bmp_ihdr.biBitCount == 4 || bmp_ihdr.biBitCount == 32 || bmp_ihdr.biBitCount == 24) || - bmp_ihdr.biCompression != 0) { - DBG_INFO(80, "Error: incompatible bitmap format!\n"); - return NULL; - } - - switch (bmp_ihdr.biBitCount) { - case 8: - case 32: - /* 8 bit, 32 bit bitmap */ - image = (uint8*)malloc(row_bytes * bmp_ihdr.biHeight); - if (image) { - tmpimage = image; - pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); - for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ - fseek(fp, pos, SEEK_SET); - fread(tmpimage, row_bytes, 1, fp); - tmpimage += row_bytes; - pos -= row_bytes; - } + if (!getBMPInfo(fp, &bmp_fhdr, &bmp_ihdr)) { + INFO(80, "error reading bitmap file! bitmap image is corrupt.\n"); + return NULL; } - break; - case 4: - /* 4bit bitmap */ - image = (uint8*)malloc((row_bytes * bmp_ihdr.biHeight) << 1); - image_row = (uint8*)malloc(row_bytes); - if (image && image_row) { - tmpimage = image; - pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); - for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ - fseek(fp, pos, SEEK_SET); - fread(image_row, row_bytes, 1, fp); - /* expand 4bpp to 8bpp. stuff 4bit values into 8bit comps. */ - for (j = 0; j < (int) row_bytes; j++) { - tmpimage[j << 1] = image_row[j] & 0x0f; - tmpimage[(j << 1) + 1] = (image_row[j] & 0xf0) >> 4; - } - tmpimage += (row_bytes << 1); - pos -= row_bytes; - } - free(image_row); - } else { - if (image_row) free(image_row); - if (image) free(image); - image = NULL; - } - break; - case 24: - /* 24 bit bitmap */ - image = (uint8*)malloc((bmp_ihdr.biWidth * bmp_ihdr.biHeight) << 2); - image_row = (uint8*)malloc(row_bytes); - if (image && image_row) { - tmpimage = image; - pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); - for (i = 0; i < bmp_ihdr.biHeight; i++) { - /* read in image */ - fseek(fp, pos, SEEK_SET); - fread(image_row, row_bytes, 1, fp); - /* convert 24bpp to 32bpp. */ - for (j = 0; j < bmp_ihdr.biWidth; j++) { - tmpimage[(j << 2)] = image_row[j * 3]; - tmpimage[(j << 2) + 1] = image_row[j * 3 + 1]; - tmpimage[(j << 2) + 2] = image_row[j * 3 + 2]; - tmpimage[(j << 2) + 3] = 0xFF; - } - tmpimage += (bmp_ihdr.biWidth << 2); - pos -= row_bytes; - } - free(image_row); - } else { - if (image_row) free(image_row); - if (image) free(image); - image = NULL; - } - } - if (image) { - *width = (row_bytes << 3) / bmp_ihdr.biBitCount; - *height = bmp_ihdr.biHeight; + DBG_INFO(80, "bmp format %d x %d bitdepth:%d compression:%x offset:%d\n", + bmp_ihdr.biWidth, bmp_ihdr.biHeight, bmp_ihdr.biBitCount, + bmp_ihdr.biCompression, bmp_fhdr.bfOffBits); + + /* rowStride in bytes */ + row_bytes = (bmp_ihdr.biWidth * bmp_ihdr.biBitCount) >> 3; + /* align to 4bytes boundary */ + row_bytes = (row_bytes + 3) & ~3; + + /* Rice hi-res textures */ + if (!(bmp_ihdr.biBitCount == 8 || bmp_ihdr.biBitCount == 4 || bmp_ihdr.biBitCount == 32 || bmp_ihdr.biBitCount == 24) || + bmp_ihdr.biCompression != 0) { + DBG_INFO(80, "Error: incompatible bitmap format!\n"); + return NULL; + } switch (bmp_ihdr.biBitCount) { case 8: - case 4: - *format = GR_TEXFMT_P_8; - break; case 32: + /* 8 bit, 32 bit bitmap */ + image = (uint8*)malloc(row_bytes * bmp_ihdr.biHeight); + if (image) { + tmpimage = image; + pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); + for (i = 0; i < bmp_ihdr.biHeight; i++) { + /* read in image */ + fseek(fp, pos, SEEK_SET); + fread(tmpimage, row_bytes, 1, fp); + tmpimage += row_bytes; + pos -= row_bytes; + } + } + break; + case 4: + /* 4bit bitmap */ + image = (uint8*)malloc((row_bytes * bmp_ihdr.biHeight) << 1); + image_row = (uint8*)malloc(row_bytes); + if (image && image_row) { + tmpimage = image; + pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); + for (i = 0; i < bmp_ihdr.biHeight; i++) { + /* read in image */ + fseek(fp, pos, SEEK_SET); + fread(image_row, row_bytes, 1, fp); + /* expand 4bpp to 8bpp. stuff 4bit values into 8bit comps. */ + for (j = 0; j < (int)row_bytes; j++) { + tmpimage[j << 1] = image_row[j] & 0x0f; + tmpimage[(j << 1) + 1] = (image_row[j] & 0xf0) >> 4; + } + tmpimage += (row_bytes << 1); + pos -= row_bytes; + } + free(image_row); + } + else { + if (image_row) free(image_row); + if (image) free(image); + image = NULL; + } + break; case 24: - *format = GR_TEXFMT_ARGB_8888; + /* 24 bit bitmap */ + image = (uint8*)malloc((bmp_ihdr.biWidth * bmp_ihdr.biHeight) << 2); + image_row = (uint8*)malloc(row_bytes); + if (image && image_row) { + tmpimage = image; + pos = bmp_fhdr.bfOffBits + row_bytes * (bmp_ihdr.biHeight - 1); + for (i = 0; i < bmp_ihdr.biHeight; i++) { + /* read in image */ + fseek(fp, pos, SEEK_SET); + fread(image_row, row_bytes, 1, fp); + /* convert 24bpp to 32bpp. */ + for (j = 0; j < bmp_ihdr.biWidth; j++) { + tmpimage[(j << 2)] = image_row[j * 3]; + tmpimage[(j << 2) + 1] = image_row[j * 3 + 1]; + tmpimage[(j << 2) + 2] = image_row[j * 3 + 2]; + tmpimage[(j << 2) + 3] = 0xFF; + } + tmpimage += (bmp_ihdr.biWidth << 2); + pos -= row_bytes; + } + free(image_row); + } + else { + if (image_row) free(image_row); + if (image) free(image); + image = NULL; + } } + if (image) { + *width = (row_bytes << 3) / bmp_ihdr.biBitCount; + *height = bmp_ihdr.biHeight; + + switch (bmp_ihdr.biBitCount) { + case 8: + case 4: + *format = GFX_TEXFMT_P_8; + break; + case 32: + case 24: + *format = GFX_TEXFMT_ARGB_8888; + } + #if POW2_TEXTURES - /* next power of 2 size conversions */ - /* NOTE: I can do this in the above loop for faster operations, but some - * texture packs require a workaround. see HACKALERT in nextPow2(). - */ + /* next power of 2 size conversions */ + /* NOTE: I can do this in the above loop for faster operations, but some + * texture packs require a workaround. see HACKALERT in nextPow2(). + */ - TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. + TxReSample txReSample = new TxReSample; // XXX: temporary. move to a better place. #if (POW2_TEXTURES == 2) - if (!txReSample->nextPow2(&image, width, height, 8, 1)) { + if (!txReSample->nextPow2(&image, width, height, 8, 1)) { #else - if (!txReSample->nextPow2(&image, width, height, 8, 0)) { + if (!txReSample->nextPow2(&image, width, height, 8, 0)) { #endif - if (image) { - free(image); - image = NULL; - } - *width = 0; - *height = 0; - *format = 0; - } + if (image) { + free(image); + image = NULL; + } + *width = 0; + *height = 0; + *format = 0; + } - delete txReSample; + delete txReSample; #endif /* POW2_TEXTURES */ - } + } #ifdef DEBUG - if (!image) { - DBG_INFO(80, "Error: failed to load bmp image!\n"); - } + if (!image) { + DBG_INFO(80, "Error: failed to load bmp image!\n"); + } #endif - return image; + return image; } -boolean +bool TxImage::getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr) { - /* - * read in DDSFILEHEADER - */ + /* + * read in DDSFILEHEADER + */ - /* is this a DDS file? */ - if (fread(&dds_fhdr->dwMagic, 4, 1, fp) != 1) - return 0; + /* is this a DDS file? */ + if (fread(&dds_fhdr->dwMagic, 4, 1, fp) != 1) + return 0; - if (memcmp(&dds_fhdr->dwMagic, "DDS ", 4) != 0) - return 0; + if (memcmp(&dds_fhdr->dwMagic, "DDS ", 4) != 0) + return 0; - if (fread(&dds_fhdr->dwSize, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwSize, 4, 1, fp) != 1) + return 0; - /* get file flags */ - if (fread(&dds_fhdr->dwFlags, 4, 1, fp) != 1) - return 0; + /* get file flags */ + if (fread(&dds_fhdr->dwFlags, 4, 1, fp) != 1) + return 0; - /* height of dds in pixels */ - if (fread(&dds_fhdr->dwHeight, 4, 1, fp) != 1) - return 0; + /* height of dds in pixels */ + if (fread(&dds_fhdr->dwHeight, 4, 1, fp) != 1) + return 0; - /* width of dds in pixels */ - if (fread(&dds_fhdr->dwWidth, 4, 1, fp) != 1) - return 0; + /* width of dds in pixels */ + if (fread(&dds_fhdr->dwWidth, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwLinearSize, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwLinearSize, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwDepth, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwDepth, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwMipMapCount, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwMipMapCount, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwReserved1, 4 * 11, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwReserved1, 4 * 11, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwSize, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwSize, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwFlags, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwFlags, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwFourCC, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwFourCC, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwRGBBitCount, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwRGBBitCount, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwRBitMask, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwRBitMask, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwGBitMask, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwGBitMask, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwBBitMask, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwBBitMask, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->ddpf.dwRGBAlphaBitMask, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->ddpf.dwRGBAlphaBitMask, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwCaps1, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwCaps1, 4, 1, fp) != 1) + return 0; - if (fread(&dds_fhdr->dwCaps2, 4, 1, fp) != 1) - return 0; + if (fread(&dds_fhdr->dwCaps2, 4, 1, fp) != 1) + return 0; - return 1; + return 1; } uint8* TxImage::readDDS(FILE* fp, int* width, int* height, uint16* format) { - uint8 *image = NULL; - DDSFILEHEADER dds_fhdr; - uint16 tmpformat = 0; + uint8 *image = NULL; + DDSFILEHEADER dds_fhdr; + uint16 tmpformat = 0; - /* initialize */ - *width = 0; - *height = 0; - *format = 0; + /* initialize */ + *width = 0; + *height = 0; + *format = 0; - /* check if we have a valid dds file */ - if (!fp) - return NULL; + /* check if we have a valid dds file */ + if (!fp) + return NULL; - if (!getDDSInfo(fp, &dds_fhdr)) { - INFO(80, "error reading dds file! dds image is corrupt.\n"); - return NULL; - } + if (!getDDSInfo(fp, &dds_fhdr)) { + INFO(80, "error reading dds file! dds image is corrupt.\n"); + return NULL; + } - DBG_INFO(80, "dds format %d x %d HeaderSize %d LinearSize %d\n", - dds_fhdr.dwWidth, dds_fhdr.dwHeight, dds_fhdr.dwSize, dds_fhdr.dwLinearSize); + DBG_INFO(80, "dds format %d x %d HeaderSize %d LinearSize %d\n", + dds_fhdr.dwWidth, dds_fhdr.dwHeight, dds_fhdr.dwSize, dds_fhdr.dwLinearSize); - if (!(dds_fhdr.dwFlags & (DDSD_CAPS|DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT|DDSD_LINEARSIZE))) { - DBG_INFO(80, "Error: incompatible dds format!\n"); - return NULL; - } + if (!(dds_fhdr.dwFlags & (DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT | DDSD_LINEARSIZE))) { + DBG_INFO(80, "Error: incompatible dds format!\n"); + return NULL; + } - if ((dds_fhdr.dwFlags & DDSD_MIPMAPCOUNT) && dds_fhdr.dwMipMapCount != 1) { - DBG_INFO(80, "Error: mipmapped dds not supported!\n"); - return NULL; - } + if ((dds_fhdr.dwFlags & DDSD_MIPMAPCOUNT) && dds_fhdr.dwMipMapCount != 1) { + DBG_INFO(80, "Error: mipmapped dds not supported!\n"); + return NULL; + } - if (!((dds_fhdr.ddpf.dwFlags & DDPF_FOURCC) && dds_fhdr.dwCaps2 == 0)) { - DBG_INFO(80, "Error: not fourcc standard texture!\n"); - return NULL; - } + if (!((dds_fhdr.ddpf.dwFlags & DDPF_FOURCC) && dds_fhdr.dwCaps2 == 0)) { + DBG_INFO(80, "Error: not fourcc standard texture!\n"); + return NULL; + } - if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT1", 4) == 0) { - DBG_INFO(80, "DXT1 format\n"); - /* compensate for missing LinearSize */ - dds_fhdr.dwLinearSize = (dds_fhdr.dwWidth * dds_fhdr.dwHeight) >> 1; - tmpformat = GR_TEXFMT_ARGB_CMP_DXT1; - } else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT3", 4) == 0) { - DBG_INFO(80, "DXT3 format\n"); - dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight; - tmpformat = GR_TEXFMT_ARGB_CMP_DXT3; - } else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT5", 4) == 0) { - DBG_INFO(80, "DXT5 format\n"); - dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight; - tmpformat = GR_TEXFMT_ARGB_CMP_DXT5; - } else { - DBG_INFO(80, "Error: not DXT1 or DXT3 or DXT5 format!\n"); - return NULL; - } + if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT1", 4) == 0) { + DBG_INFO(80, "DXT1 format\n"); + /* compensate for missing LinearSize */ + dds_fhdr.dwLinearSize = (dds_fhdr.dwWidth * dds_fhdr.dwHeight) >> 1; + tmpformat = GFX_TEXFMT_ARGB_CMP_DXT1; + } + else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT3", 4) == 0) { + DBG_INFO(80, "DXT3 format\n"); + dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight; + tmpformat = GFX_TEXFMT_ARGB_CMP_DXT3; + } + else if (memcmp(&dds_fhdr.ddpf.dwFourCC, "DXT5", 4) == 0) { + DBG_INFO(80, "DXT5 format\n"); + dds_fhdr.dwLinearSize = dds_fhdr.dwWidth * dds_fhdr.dwHeight; + tmpformat = GFX_TEXFMT_ARGB_CMP_DXT5; + } + else { + DBG_INFO(80, "Error: not DXT1 or DXT3 or DXT5 format!\n"); + return NULL; + } - /* read in image */ - image = (uint8*)malloc(dds_fhdr.dwLinearSize); - if (image) { - *width = dds_fhdr.dwWidth; - *height = dds_fhdr.dwHeight; - *format = tmpformat; + /* read in image */ + image = (uint8*)malloc(dds_fhdr.dwLinearSize); + if (image) { + *width = dds_fhdr.dwWidth; + *height = dds_fhdr.dwHeight; + *format = tmpformat; - fseek(fp, 128, SEEK_SET); /* size of header is 128 bytes */ - fread(image, dds_fhdr.dwLinearSize, 1, fp); - } + fseek(fp, 128, SEEK_SET); /* size of header is 128 bytes */ + fread(image, dds_fhdr.dwLinearSize, 1, fp); + } - return image; -} + return image; +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxImage.h b/Source/Project64-video/TextureEnhancer/TxImage.h index 64331f537..66a8eeb49 100644 --- a/Source/Project64-video/TextureEnhancer/TxImage.h +++ b/Source/Project64-video/TextureEnhancer/TxImage.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXIMAGE_H__ #define __TXIMAGE_H__ @@ -28,32 +19,27 @@ #include #include "TxInternal.h" -#ifndef WIN32 typedef struct tagBITMAPFILEHEADER { - unsigned short bfType; - unsigned long bfSize; - unsigned short bfReserved1; - unsigned short bfReserved2; - unsigned long bfOffBits; + unsigned short bfType; + unsigned long bfSize; + unsigned short bfReserved1; + unsigned short bfReserved2; + unsigned long bfOffBits; } BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER { - unsigned long biSize; - long biWidth; - long biHeight; - unsigned short biPlanes; - unsigned short biBitCount; - unsigned long biCompression; - unsigned long biSizeImage; - long biXPelsPerMeter; - long biYPelsPerMeter; - unsigned long biClrUsed; - unsigned long biClrImportant; + unsigned long biSize; + long biWidth; + long biHeight; + unsigned short biPlanes; + unsigned short biBitCount; + unsigned long biCompression; + unsigned long biSizeImage; + long biXPelsPerMeter; + long biYPelsPerMeter; + unsigned long biClrUsed; + unsigned long biClrImportant; } BITMAPINFOHEADER; -#else -typedef struct tagBITMAPFILEHEADER BITMAPFILEHEADER; -typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER; -#endif #define DDSD_CAPS 0x00000001 #define DDSD_HEIGHT 0x00000002 @@ -73,44 +59,44 @@ typedef struct tagBITMAPINFOHEADER BITMAPINFOHEADER; #define DDSCAPS_MIPMAP 0x00400000 typedef struct tagDDSPIXELFORMAT { - unsigned long dwSize; - unsigned long dwFlags; - unsigned long dwFourCC; - unsigned long dwRGBBitCount; - unsigned long dwRBitMask; - unsigned long dwGBitMask; - unsigned long dwBBitMask; - unsigned long dwRGBAlphaBitMask; + unsigned long dwSize; + unsigned long dwFlags; + unsigned long dwFourCC; + unsigned long dwRGBBitCount; + unsigned long dwRBitMask; + unsigned long dwGBitMask; + unsigned long dwBBitMask; + unsigned long dwRGBAlphaBitMask; } DDSPIXELFORMAT; typedef struct tagDDSFILEHEADER { - unsigned long dwMagic; - unsigned long dwSize; - unsigned long dwFlags; - unsigned long dwHeight; - unsigned long dwWidth; - unsigned long dwLinearSize; - unsigned long dwDepth; - unsigned long dwMipMapCount; - unsigned long dwReserved1[11]; - DDSPIXELFORMAT ddpf; - unsigned long dwCaps1; - unsigned long dwCaps2; + unsigned long dwMagic; + unsigned long dwSize; + unsigned long dwFlags; + unsigned long dwHeight; + unsigned long dwWidth; + unsigned long dwLinearSize; + unsigned long dwDepth; + unsigned long dwMipMapCount; + unsigned long dwReserved1[11]; + DDSPIXELFORMAT ddpf; + unsigned long dwCaps1; + unsigned long dwCaps2; } DDSFILEHEADER; class TxImage { private: - boolean getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr); - boolean getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr); - boolean getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr); + bool getPNGInfo(FILE *fp, png_structp *png_ptr, png_infop *info_ptr); + bool getBMPInfo(FILE *fp, BITMAPFILEHEADER *bmp_fhdr, BITMAPINFOHEADER *bmp_ihdr); + bool getDDSInfo(FILE *fp, DDSFILEHEADER *dds_fhdr); public: - TxImage() {} - ~TxImage() {} - uint8* readPNG(FILE* fp, int* width, int* height, uint16* format); - boolean writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette); - uint8* readBMP(FILE* fp, int* width, int* height, uint16* format); - uint8* readDDS(FILE* fp, int* width, int* height, uint16* format); + TxImage() {} + ~TxImage() {} + uint8* readPNG(FILE* fp, int* width, int* height, uint16* format); + bool writePNG(uint8* src, FILE* fp, int width, int height, int rowStride, uint16 format, uint8 *palette); + uint8* readBMP(FILE* fp, int* width, int* height, uint16* format); + uint8* readDDS(FILE* fp, int* width, int* height, uint16* format); }; #endif /* __TXIMAGE_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxInternal.h b/Source/Project64-video/TextureEnhancer/TxInternal.h index 91b2f0f56..e17b10f83 100644 --- a/Source/Project64-video/TextureEnhancer/TxInternal.h +++ b/Source/Project64-video/TextureEnhancer/TxInternal.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __INTERNAL_H__ #define __INTERNAL_H__ diff --git a/Source/Project64-video/TextureEnhancer/TxQuantize.cpp b/Source/Project64-video/TextureEnhancer/TxQuantize.cpp index d64612e8c..1f3e75a92 100644 --- a/Source/Project64-video/TextureEnhancer/TxQuantize.cpp +++ b/Source/Project64-video/TextureEnhancer/TxQuantize.cpp @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef WIN32 #pragma warning(disable: 4786) @@ -28,132 +19,132 @@ /* NOTE: The codes are not optimized. They can be made faster. */ #include "TxQuantize.h" +#include TxQuantize::TxQuantize() { - _txUtil = new TxUtil(); + _txUtil = new TxUtil(); - /* get number of CPU cores. */ - _numcore = _txUtil->getNumberofProcessors(); + /* get number of CPU cores. */ + _numcore = _txUtil->getNumberofProcessors(); - /* get dxtn extensions */ - _tx_compress_fxt1 = TxLoadLib::getInstance()->getfxtCompressTexFuncExt(); - _tx_compress_dxtn = TxLoadLib::getInstance()->getdxtCompressTexFuncExt(); + /* get dxtn extensions */ + _tx_compress_fxt1 = TxLoadLib::getInstance()->getfxtCompressTexFuncExt(); + _tx_compress_dxtn = TxLoadLib::getInstance()->getdxtCompressTexFuncExt(); } - TxQuantize::~TxQuantize() { - delete _txUtil; + delete _txUtil; } void TxQuantize::ARGB1555_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (((*src & 0x00008000) ? 0xff000000 : 0x00000000) | + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (((*src & 0x00008000) ? 0xff000000 : 0x00000000) | ((*src & 0x00007c00) << 9) | ((*src & 0x00007000) << 4) | ((*src & 0x000003e0) << 6) | ((*src & 0x00000380) << 1) | ((*src & 0x0000001f) << 3) | ((*src & 0x0000001c) >> 2)); - dest++; - *dest = (((*src & 0x80000000) ? 0xff000000 : 0x00000000) | - ((*src & 0x7c000000) >> 7) | ((*src & 0x70000000) >> 12) | + dest++; + *dest = (((*src & 0x80000000) ? 0xff000000 : 0x00000000) | + ((*src & 0x7c000000) >> 7) | ((*src & 0x70000000) >> 12) | ((*src & 0x03e00000) >> 10) | ((*src & 0x03800000) >> 15) | ((*src & 0x001f0000) >> 13) | ((*src & 0x001c0000) >> 18)); - dest++; - src++; - } + dest++; + src++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // arrr rrgg gggb bbbb - // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov edx, eax; // edx = arrrrrgg gggbbbbb arrrrrgg gggbbbbb - mov ebx, 0x00000000; - and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 - jz transparent1; - mov ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 + // arrr rrgg gggb bbbb + // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov edx, eax; // edx = arrrrrgg gggbbbbb arrrrrgg gggbbbbb + mov ebx, 0x00000000; + and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 + jz transparent1; + mov ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 - transparent1: - mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb - and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 - shl edx, 4; // edx = 00000000 00000rrr rr000000 00000000 - or ebx, edx; // ebx = aaaaaaaa 00000rrr rr000000 00000000 - shl edx, 5; // edx = 00000000 rrrrr000 00000000 00000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr rr000000 00000000 - and ebx, 0xffff0000; // ebx = aaaaaaaa rrrrrrrr 00000000 00000000 - mov edx, eax; - and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 - shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr 00000ggg gg000000 - shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg gg000000 - and ebx, 0xffffff00; // ebx = aaaaaaaa rrrrrrrr gggggggg 00000000 - mov edx, eax; - and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb - shl edx, 3; // edx = 00000000 00000000 00000000 bbbbb000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbb000 - shr edx, 5; // edx = 00000000 00000000 00000000 00000bbb - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + transparent1: + mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb + and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 + shl edx, 4; // edx = 00000000 00000rrr rr000000 00000000 + or ebx, edx; // ebx = aaaaaaaa 00000rrr rr000000 00000000 + shl edx, 5; // edx = 00000000 rrrrr000 00000000 00000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr rr000000 00000000 + and ebx, 0xffff0000; // ebx = aaaaaaaa rrrrrrrr 00000000 00000000 + mov edx, eax; + and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 + shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr 00000ggg gg000000 + shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg gg000000 + and ebx, 0xffffff00; // ebx = aaaaaaaa rrrrrrrr gggggggg 00000000 + mov edx, eax; + and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb + shl edx, 3; // edx = 00000000 00000000 00000000 bbbbb000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbb000 + shr edx, 5; // edx = 00000000 00000000 00000000 00000bbb + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], ebx; - add edi, 4; + mov dword ptr[edi], ebx; + add edi, 4; - shr eax, 16; // eax = 00000000 00000000 arrrrrgg gggbbbbb - mov edx, eax; // edx = 00000000 00000000 arrrrrgg gggbbbbb - mov ebx, 0x00000000; - and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 - jz transparent2; - mov ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 + shr eax, 16; // eax = 00000000 00000000 arrrrrgg gggbbbbb + mov edx, eax; // edx = 00000000 00000000 arrrrrgg gggbbbbb + mov ebx, 0x00000000; + and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 + jz transparent2; + mov ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 - transparent2: - mov eax, edx; // eax = 00000000 00000000 arrrrrgg gggbbbbb - and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 - shl edx, 4; // edx = 00000000 00000rrr rr000000 00000000 - or ebx, edx; // ebx = aaaaaaaa 00000rrr rr000000 00000000 - shl edx, 5; // edx = 00000000 rrrrr000 00000000 00000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr rr000000 00000000 - and ebx, 0xffff0000; // ebx = aaaaaaaa rrrrrrrr 00000000 00000000 - mov edx, eax; - and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 - shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr 00000ggg gg000000 - shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg gg000000 - and ebx, 0xffffff00; // ebx = aaaaaaaa rrrrrrrr gggggggg 00000000 - mov edx, eax; - and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb - shl edx, 3; // edx = 00000000 00000000 00000000 bbbbb000 - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbb000 - shr edx, 5; // edx = 00000000 00000000 00000000 00000bbb - or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + transparent2: + mov eax, edx; // eax = 00000000 00000000 arrrrrgg gggbbbbb + and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 + shl edx, 4; // edx = 00000000 00000rrr rr000000 00000000 + or ebx, edx; // ebx = aaaaaaaa 00000rrr rr000000 00000000 + shl edx, 5; // edx = 00000000 rrrrr000 00000000 00000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr rr000000 00000000 + and ebx, 0xffff0000; // ebx = aaaaaaaa rrrrrrrr 00000000 00000000 + mov edx, eax; + and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 + shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr 00000ggg gg000000 + shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg gg000000 + and ebx, 0xffffff00; // ebx = aaaaaaaa rrrrrrrr gggggggg 00000000 + mov edx, eax; + and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb + shl edx, 3; // edx = 00000000 00000000 00000000 bbbbb000 + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbb000 + shr edx, 5; // edx = 00000000 00000000 00000000 00000bbb + or ebx, edx; // ebx = aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], ebx; - add edi, 4; + mov dword ptr[edi], ebx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -161,91 +152,91 @@ void TxQuantize::ARGB4444_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = ((*src & 0x0000f000) << 12) | + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = ((*src & 0x0000f000) << 12) | ((*src & 0x00000f00) << 8) | ((*src & 0x000000f0) << 4) | - (*src & 0x0000000f); - *dest |= (*dest << 4); - dest++; - *dest = ((*src & 0xf0000000) | + (*src & 0x0000000f); + *dest |= (*dest << 4); + dest++; + *dest = ((*src & 0xf0000000) | ((*src & 0x0f000000) >> 4) | ((*src & 0x00f00000) >> 8) | ((*src & 0x000f0000) >> 12)); - *dest |= (*dest >> 4); - dest++; - src++; - } + *dest |= (*dest >> 4); + dest++; + src++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaa rrrr gggg bbbb - // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov edx, eax; - and eax, 0x0000ffff; - mov ebx, eax; // 00000000 00000000 aaaarrrr ggggbbbb - and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 - shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 - or eax, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 - shl ebx, 8; // 00000000 0000rrrr 00000000 00000000 - or eax, ebx; // 0000aaaa 0000rrrr aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 - shl ebx, 4; // 00000000 00000000 0000gggg 00000000 - and eax, 0x0f0f000f; // 0000aaaa 0000rrrr 00000000 0000bbbb - or eax, ebx; // 0000aaaa 0000rrrr 0000gggg 0000bbbb - mov ebx, eax; - shl ebx, 4; // aaaa0000 rrrr0000 gggg0000 bbbb0000 - or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + // aaaa rrrr gggg bbbb + // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov edx, eax; + and eax, 0x0000ffff; + mov ebx, eax; // 00000000 00000000 aaaarrrr ggggbbbb + and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 + shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 + or eax, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 + shl ebx, 8; // 00000000 0000rrrr 00000000 00000000 + or eax, ebx; // 0000aaaa 0000rrrr aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 + shl ebx, 4; // 00000000 00000000 0000gggg 00000000 + and eax, 0x0f0f000f; // 0000aaaa 0000rrrr 00000000 0000bbbb + or eax, ebx; // 0000aaaa 0000rrrr 0000gggg 0000bbbb + mov ebx, eax; + shl ebx, 4; // aaaa0000 rrrr0000 gggg0000 bbbb0000 + or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - shr edx, 16; - mov ebx, edx; // 00000000 00000000 aaaarrrr ggggbbbb - and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 - shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 - or edx, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb - mov ebx, edx; - and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 - shl ebx, 8; // 00000000 0000rrrr 00000000 00000000 - or edx, ebx; // 0000aaaa 0000rrrr aaaarrrr ggggbbbb - mov ebx, edx; - and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 - shl ebx, 4; // 00000000 00000000 0000gggg 00000000 - and edx, 0x0f0f000f; // 0000aaaa 0000rrrr 00000000 0000bbbb - or edx, ebx; // 0000aaaa 0000rrrr 0000gggg 0000bbbb - mov ebx, edx; - shl ebx, 4; // aaaa0000 rrrr0000 gggg0000 bbbb0000 - or edx, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + shr edx, 16; + mov ebx, edx; // 00000000 00000000 aaaarrrr ggggbbbb + and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 + shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 + or edx, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb + mov ebx, edx; + and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 + shl ebx, 8; // 00000000 0000rrrr 00000000 00000000 + or edx, ebx; // 0000aaaa 0000rrrr aaaarrrr ggggbbbb + mov ebx, edx; + and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 + shl ebx, 4; // 00000000 00000000 0000gggg 00000000 + and edx, 0x0f0f000f; // 0000aaaa 0000rrrr 00000000 0000bbbb + or edx, ebx; // 0000aaaa 0000rrrr 0000gggg 0000bbbb + mov ebx, edx; + shl ebx, 4; // aaaa0000 rrrr0000 gggg0000 bbbb0000 + or edx, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -253,97 +244,97 @@ void TxQuantize::RGB565_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (0xff000000 | + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (0xff000000 | ((*src & 0x0000f800) << 8) | ((*src & 0x0000e000) << 3) | ((*src & 0x000007e0) << 5) | ((*src & 0x00000600) >> 1) | ((*src & 0x0000001f) << 3) | ((*src & 0x0000001c) >> 2)); - dest++; - *dest = (0xff000000 | - ((*src & 0xf8000000) >> 8) | ((*src & 0xe0000000) >> 13) | + dest++; + *dest = (0xff000000 | + ((*src & 0xf8000000) >> 8) | ((*src & 0xe0000000) >> 13) | ((*src & 0x07e00000) >> 11) | ((*src & 0x06000000) >> 17) | ((*src & 0x001f0000) >> 13) | ((*src & 0x001c0000) >> 18)); - dest++; - src++; - } + dest++; + src++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // rrrr rggg gggb bbbb - // 11111111 rrrrrrrr gggggggg bbbbbbbb - mov edx, eax; - and eax, 0x0000ffff; - mov ebx, eax; // 00000000 00000000 rrrrrggg gggbbbbb - and ebx, 0x0000f800; // 00000000 00000000 rrrrr000 00000000 - shl ebx, 5; // 00000000 000rrrrr 00000000 00000000 - or eax, ebx; // 00000000 000rrrrr rrrrrggg gggbbbbb - mov ebx, eax; - and ebx, 0x000007e0; // 00000000 00000000 00000ggg ggg00000 - shl ebx, 5; // 00000000 00000000 gggggg00 00000000 - and eax, 0x001F001F; // 00000000 000rrrrr 00000000 000bbbbb - shl eax, 3; // 00000000 rrrrr000 00000000 bbbbb000 - or eax, ebx; // 00000000 rrrrr000 gggggg00 bbbbb000 - mov ebx, eax; - shr ebx, 5; // 00000000 00000rrr rr000ggg ggg00bbb - and ebx, 0x00070007; // 00000000 00000rrr 00000000 00000bbb - or eax, ebx; // 00000000 rrrrrrrr gggggg00 bbbbbbbb - mov ebx, eax; - shr ebx, 6; - and ebx, 0x00000300; // 00000000 00000000 000000gg 00000000 - or eax, ebx // 00000000 rrrrrrrr gggggggg bbbbbbbb - or eax, 0xff000000; // 11111111 rrrrrrrr gggggggg bbbbbbbb + // rrrr rggg gggb bbbb + // 11111111 rrrrrrrr gggggggg bbbbbbbb + mov edx, eax; + and eax, 0x0000ffff; + mov ebx, eax; // 00000000 00000000 rrrrrggg gggbbbbb + and ebx, 0x0000f800; // 00000000 00000000 rrrrr000 00000000 + shl ebx, 5; // 00000000 000rrrrr 00000000 00000000 + or eax, ebx; // 00000000 000rrrrr rrrrrggg gggbbbbb + mov ebx, eax; + and ebx, 0x000007e0; // 00000000 00000000 00000ggg ggg00000 + shl ebx, 5; // 00000000 00000000 gggggg00 00000000 + and eax, 0x001F001F; // 00000000 000rrrrr 00000000 000bbbbb + shl eax, 3; // 00000000 rrrrr000 00000000 bbbbb000 + or eax, ebx; // 00000000 rrrrr000 gggggg00 bbbbb000 + mov ebx, eax; + shr ebx, 5; // 00000000 00000rrr rr000ggg ggg00bbb + and ebx, 0x00070007; // 00000000 00000rrr 00000000 00000bbb + or eax, ebx; // 00000000 rrrrrrrr gggggg00 bbbbbbbb + mov ebx, eax; + shr ebx, 6; + and ebx, 0x00000300; // 00000000 00000000 000000gg 00000000 + or eax, ebx // 00000000 rrrrrrrr gggggggg bbbbbbbb + or eax, 0xff000000; // 11111111 rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - shr edx, 16; - mov eax, edx; // 00000000 00000000 rrrrrggg gggbbbbb - and eax, 0x0000ffff; - mov ebx, eax; // 00000000 00000000 rrrrrggg gggbbbbb - and ebx, 0x0000f800; // 00000000 00000000 rrrrr000 00000000 - shl ebx, 5; // 00000000 000rrrrr 00000000 00000000 - or eax, ebx; // 00000000 000rrrrr rrrrrggg gggbbbbb - mov ebx, eax; - and ebx, 0x000007e0; // 00000000 00000000 00000ggg ggg00000 - shl ebx, 5; // 00000000 00000000 gggggg00 00000000 - and eax, 0x001F001F; // 00000000 000rrrrr 00000000 000bbbbb - shl eax, 3; // 00000000 rrrrr000 00000000 bbbbb000 - or eax, ebx; // 00000000 rrrrr000 gggggg00 bbbbb000 - mov ebx, eax; - shr ebx, 5; // 00000000 00000rrr rr000ggg ggg00bbb - and ebx, 0x00070007; // 00000000 00000rrr 00000000 00000bbb - or eax, ebx; // 00000000 rrrrrrrr gggggg00 bbbbbbbb - mov ebx, eax; - shr ebx, 6; - and ebx, 0x00000300; // 00000000 00000000 000000gg 00000000 - or eax, ebx // 00000000 rrrrrrrr gggggggg bbbbbbbb - or eax, 0xff000000; // 11111111 rrrrrrrr gggggggg bbbbbbbb + shr edx, 16; + mov eax, edx; // 00000000 00000000 rrrrrggg gggbbbbb + and eax, 0x0000ffff; + mov ebx, eax; // 00000000 00000000 rrrrrggg gggbbbbb + and ebx, 0x0000f800; // 00000000 00000000 rrrrr000 00000000 + shl ebx, 5; // 00000000 000rrrrr 00000000 00000000 + or eax, ebx; // 00000000 000rrrrr rrrrrggg gggbbbbb + mov ebx, eax; + and ebx, 0x000007e0; // 00000000 00000000 00000ggg ggg00000 + shl ebx, 5; // 00000000 00000000 gggggg00 00000000 + and eax, 0x001F001F; // 00000000 000rrrrr 00000000 000bbbbb + shl eax, 3; // 00000000 rrrrr000 00000000 bbbbb000 + or eax, ebx; // 00000000 rrrrr000 gggggg00 bbbbb000 + mov ebx, eax; + shr ebx, 5; // 00000000 00000rrr rr000ggg ggg00bbb + and ebx, 0x00070007; // 00000000 00000rrr 00000000 00000bbb + or eax, ebx; // 00000000 rrrrrrrr gggggg00 bbbbbbbb + mov ebx, eax; + shr ebx, 6; + and ebx, 0x00000300; // 00000000 00000000 000000gg 00000000 + or eax, ebx // 00000000 rrrrrrrr gggggggg bbbbbbbb + or eax, 0xff000000; // 11111111 rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -351,100 +342,100 @@ void TxQuantize::A8_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 2; - int i; - for (i = 0; i < siz; i++) { - *dest = (*src & 0x000000ff); - *dest |= (*dest << 8); - *dest |= (*dest << 16); - dest++; - *dest = (*src & 0x0000ff00); - *dest |= (*dest >> 8); - *dest |= (*dest << 16); - dest++; - *dest = (*src & 0x00ff0000); - *dest |= (*dest << 8); - *dest |= (*dest >> 16); - dest++; - *dest = (*src & 0xff000000); - *dest |= (*dest >> 8); - *dest |= (*dest >> 16); - dest++; - src++; - } + int siz = (width * height) >> 2; + int i; + for (i = 0; i < siz; i++) { + *dest = (*src & 0x000000ff); + *dest |= (*dest << 8); + *dest |= (*dest << 16); + dest++; + *dest = (*src & 0x0000ff00); + *dest |= (*dest >> 8); + *dest |= (*dest << 16); + dest++; + *dest = (*src & 0x00ff0000); + *dest |= (*dest << 8); + *dest |= (*dest >> 16); + dest++; + *dest = (*src & 0xff000000); + *dest |= (*dest >> 8); + *dest |= (*dest >> 16); + dest++; + src++; + } #else - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaaaaaa - // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov edx, eax; - and eax, 0x000000ff; - mov ebx, eax; // 00000000 00000000 00000000 aaaaaaaa - shl ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 - or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa - mov ebx, eax; - shl ebx, 16; // aaaaaaaa aaaaaaaa 00000000 00000000 - or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + // aaaaaaaa + // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov edx, eax; + and eax, 0x000000ff; + mov ebx, eax; // 00000000 00000000 00000000 aaaaaaaa + shl ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 + or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa + mov ebx, eax; + shl ebx, 16; // aaaaaaaa aaaaaaaa 00000000 00000000 + or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x0000ff00; - mov ebx, eax; // 00000000 00000000 aaaaaaaa 00000000 - shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa - or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa - mov ebx, eax; - shl ebx, 16; // aaaaaaaa aaaaaaaa 00000000 00000000 - or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov eax, edx; + and eax, 0x0000ff00; + mov ebx, eax; // 00000000 00000000 aaaaaaaa 00000000 + shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa + or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa + mov ebx, eax; + shl ebx, 16; // aaaaaaaa aaaaaaaa 00000000 00000000 + or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x00ff0000; - mov ebx, eax; // 00000000 aaaaaaaa 00000000 00000000 - shl ebx, 8; // aaaaaaaa 00000000 00000000 00000000 - or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 - mov ebx, eax; - shr ebx, 16; // 00000000 00000000 aaaaaaaa aaaaaaaa - or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov eax, edx; + and eax, 0x00ff0000; + mov ebx, eax; // 00000000 aaaaaaaa 00000000 00000000 + shl ebx, 8; // aaaaaaaa 00000000 00000000 00000000 + or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 + mov ebx, eax; + shr ebx, 16; // 00000000 00000000 aaaaaaaa aaaaaaaa + or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0xff000000; - mov ebx, eax; // aaaaaaaa 00000000 00000000 00000000 - shr ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 - or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 - mov ebx, eax; - shr ebx, 16; // 00000000 00000000 aaaaaaaa aaaaaaaa - or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb + mov eax, edx; + and eax, 0xff000000; + mov ebx, eax; // aaaaaaaa 00000000 00000000 00000000 + shr ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 + or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 + mov ebx, eax; + shr ebx, 16; // 00000000 00000000 aaaaaaaa aaaaaaaa + or eax, ebx; // aaaaaaaa rrrrrrrr gggggggg bbbbbbbb - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -452,124 +443,124 @@ void TxQuantize::AI44_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 2; - int i; - for (i = 0; i < siz; i++) { - *dest = (*src & 0x0000000f); - *dest |= ((*dest << 8) | (*dest << 16)); - *dest |= ((*src & 0x000000f0) << 20); - *dest |= (*dest << 4); - dest++; - *dest = (*src & 0x00000f00); - *dest |= ((*dest << 8) | (*dest >> 8)); - *dest |= ((*src & 0x0000f000) << 12); - *dest |= (*dest << 4); - dest++; - *dest = (*src & 0x000f0000); - *dest |= ((*dest >> 8) | (*dest >> 16)); - *dest |= ((*src & 0x00f00000) << 4); - *dest |= (*dest << 4); - dest++; - *dest = ((*src & 0x0f000000) >> 4); - *dest |= ((*dest >> 8) | (*dest >> 16)); - *dest |= (*src & 0xf0000000); - *dest |= (*dest >> 4); - dest++; - src++; - } + int siz = (width * height) >> 2; + int i; + for (i = 0; i < siz; i++) { + *dest = (*src & 0x0000000f); + *dest |= ((*dest << 8) | (*dest << 16)); + *dest |= ((*src & 0x000000f0) << 20); + *dest |= (*dest << 4); + dest++; + *dest = (*src & 0x00000f00); + *dest |= ((*dest << 8) | (*dest >> 8)); + *dest |= ((*src & 0x0000f000) << 12); + *dest |= (*dest << 4); + dest++; + *dest = (*src & 0x000f0000); + *dest |= ((*dest >> 8) | (*dest >> 16)); + *dest |= ((*src & 0x00f00000) << 4); + *dest |= (*dest << 4); + dest++; + *dest = ((*src & 0x0f000000) >> 4); + *dest |= ((*dest >> 8) | (*dest >> 16)); + *dest |= (*src & 0xf0000000); + *dest |= (*dest >> 4); + dest++; + src++; + } #else - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaaiiii - // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov edx, eax; - and eax, 0x000000f0; // 00000000 00000000 00000000 aaaa0000 - mov ebx, edx; - shl eax, 20; // 0000aaaa 00000000 00000000 00000000 - and ebx, 0x0000000f; // 00000000 00000000 00000000 0000iiii - or eax, ebx; // 0000aaaa 00000000 00000000 0000iiii - shl ebx, 8; // 00000000 00000000 0000iiii 00000000 - or eax, ebx; // 0000aaaa 00000000 0000iiii 0000iiii - shl ebx, 8; // 00000000 0000iiii 00000000 00000000 - or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii - mov ebx, eax; - shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + // aaaaiiii + // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov edx, eax; + and eax, 0x000000f0; // 00000000 00000000 00000000 aaaa0000 + mov ebx, edx; + shl eax, 20; // 0000aaaa 00000000 00000000 00000000 + and ebx, 0x0000000f; // 00000000 00000000 00000000 0000iiii + or eax, ebx; // 0000aaaa 00000000 00000000 0000iiii + shl ebx, 8; // 00000000 00000000 0000iiii 00000000 + or eax, ebx; // 0000aaaa 00000000 0000iiii 0000iiii + shl ebx, 8; // 00000000 0000iiii 00000000 00000000 + or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii + mov ebx, eax; + shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 - mov ebx, edx; - shl eax, 12; // 0000aaaa 00000000 00000000 00000000 - and ebx, 0x00000f00; // 00000000 00000000 0000iiii 00000000 - or eax, ebx; // 0000aaaa 00000000 0000iiii 00000000 - shr ebx, 8; // 00000000 00000000 00000000 0000iiii - or eax, ebx; // 0000aaaa 00000000 0000iiii 0000iiii - shl ebx, 16; // 00000000 0000iiii 00000000 00000000 - or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii - mov ebx, eax; - shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov eax, edx; + and eax, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 + mov ebx, edx; + shl eax, 12; // 0000aaaa 00000000 00000000 00000000 + and ebx, 0x00000f00; // 00000000 00000000 0000iiii 00000000 + or eax, ebx; // 0000aaaa 00000000 0000iiii 00000000 + shr ebx, 8; // 00000000 00000000 00000000 0000iiii + or eax, ebx; // 0000aaaa 00000000 0000iiii 0000iiii + shl ebx, 16; // 00000000 0000iiii 00000000 00000000 + or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii + mov ebx, eax; + shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x00f00000; // 00000000 aaaa0000 00000000 00000000 - mov ebx, edx; - shl eax, 4; // 0000aaaa 00000000 00000000 00000000 - and ebx, 0x000f0000; // 00000000 0000iiii 00000000 00000000 - or eax, ebx; // 0000aaaa 0000iiii 00000000 00000000 - shr ebx, 8; // 00000000 00000000 0000iiii 00000000 - or eax, ebx; // 0000aaaa 0000iiii 0000iiii 00000000 - shr ebx, 8; // 00000000 00000000 00000000 0000iiii - or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii - mov ebx, eax; - shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov eax, edx; + and eax, 0x00f00000; // 00000000 aaaa0000 00000000 00000000 + mov ebx, edx; + shl eax, 4; // 0000aaaa 00000000 00000000 00000000 + and ebx, 0x000f0000; // 00000000 0000iiii 00000000 00000000 + or eax, ebx; // 0000aaaa 0000iiii 00000000 00000000 + shr ebx, 8; // 00000000 00000000 0000iiii 00000000 + or eax, ebx; // 0000aaaa 0000iiii 0000iiii 00000000 + shr ebx, 8; // 00000000 00000000 00000000 0000iiii + or eax, ebx; // 0000aaaa 0000iiii 0000iiii 0000iiii + mov ebx, eax; + shl ebx, 4; // aaaa0000 iiii0000 iiii0000 iiii0000 + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0xf0000000; // aaaa0000 00000000 00000000 00000000 - mov ebx, edx; - and ebx, 0x0f000000; // 0000iiii 00000000 00000000 00000000 - shr ebx, 4; // 00000000 iiii0000 00000000 00000000 - or eax, ebx; // aaaa0000 iiii0000 00000000 00000000 - shr ebx, 8; // 00000000 00000000 iiii0000 00000000 - or eax, ebx; // aaaa0000 iiii0000 iiii0000 00000000 - shr ebx, 8; // 00000000 00000000 00000000 iiii0000 - or eax, ebx; // aaaa0000 iiii0000 iiii0000 iiii0000 - mov ebx, eax; - shr ebx, 4; // 0000aaaa 0000iiii 0000iiii 0000iiii - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov eax, edx; + and eax, 0xf0000000; // aaaa0000 00000000 00000000 00000000 + mov ebx, edx; + and ebx, 0x0f000000; // 0000iiii 00000000 00000000 00000000 + shr ebx, 4; // 00000000 iiii0000 00000000 00000000 + or eax, ebx; // aaaa0000 iiii0000 00000000 00000000 + shr ebx, 8; // 00000000 00000000 iiii0000 00000000 + or eax, ebx; // aaaa0000 iiii0000 iiii0000 00000000 + shr ebx, 8; // 00000000 00000000 00000000 iiii0000 + or eax, ebx; // aaaa0000 iiii0000 iiii0000 iiii0000 + mov ebx, eax; + shr ebx, 4; // 0000aaaa 0000iiii 0000iiii 0000iiii + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -577,68 +568,68 @@ void TxQuantize::AI88_ARGB8888(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (*src & 0x000000ff); - *dest |= ((*dest << 8) | (*dest << 16)); - *dest |= ((*src & 0x0000ff00) << 16); - dest++; - *dest = (*src & 0x00ff0000); - *dest |= ((*dest >> 8) | (*dest >> 16)); - *dest |= (*src & 0xff000000); - dest++; - src++; - } + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (*src & 0x000000ff); + *dest |= ((*dest << 8) | (*dest << 16)); + *dest |= ((*src & 0x0000ff00) << 16); + dest++; + *dest = (*src & 0x00ff0000); + *dest |= ((*dest >> 8) | (*dest >> 16)); + *dest |= (*src & 0xff000000); + dest++; + src++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaaaaaa iiiiiiii - // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov edx, eax; - and eax, 0x0000ffff; // 00000000 00000000 aaaaaaaa iiiiiiii - mov ebx, eax; // 00000000 00000000 aaaaaaaa iiiiiiii - shl eax, 16; // aaaaaaaa iiiiiiii 00000000 00000000 - and ebx, 0x000000ff; // 00000000 00000000 00000000 iiiiiiii - or eax, ebx; // aaaaaaaa iiiiiiii 00000000 iiiiiiii - shl ebx, 8; // 00000000 00000000 iiiiiiii 00000000 - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + // aaaaaaaa iiiiiiii + // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov edx, eax; + and eax, 0x0000ffff; // 00000000 00000000 aaaaaaaa iiiiiiii + mov ebx, eax; // 00000000 00000000 aaaaaaaa iiiiiiii + shl eax, 16; // aaaaaaaa iiiiiiii 00000000 00000000 + and ebx, 0x000000ff; // 00000000 00000000 00000000 iiiiiiii + or eax, ebx; // aaaaaaaa iiiiiiii 00000000 iiiiiiii + shl ebx, 8; // 00000000 00000000 iiiiiiii 00000000 + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0xffff0000; // aaaaaaaa iiiiiiii 00000000 00000000 - mov ebx, eax; // aaaaaaaa iiiiiiii 00000000 00000000 - and ebx, 0x00ff0000; // 00000000 iiiiiiii 00000000 00000000 - shr ebx, 8; // 00000000 00000000 iiiiiiii 00000000 - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii 00000000 - shr ebx, 8; // 00000000 00000000 00000000 iiiiiiii - or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii + mov eax, edx; + and eax, 0xffff0000; // aaaaaaaa iiiiiiii 00000000 00000000 + mov ebx, eax; // aaaaaaaa iiiiiiii 00000000 00000000 + and ebx, 0x00ff0000; // 00000000 iiiiiiii 00000000 00000000 + shr ebx, 8; // 00000000 00000000 iiiiiiii 00000000 + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii 00000000 + shr ebx, 8; // 00000000 00000000 00000000 iiiiiiii + or eax, ebx; // aaaaaaaa iiiiiiii iiiiiiii iiiiiiii - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -646,123 +637,123 @@ void TxQuantize::ARGB8888_ARGB1555(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = ((*src & 0xff000000) ? 0x00008000 : 0x00000000); - *dest |= (((*src & 0x00f80000) >> 9) | - ((*src & 0x0000f800) >> 6) | - ((*src & 0x000000f8) >> 3)); - src++; - *dest |= ((*src & 0xff000000) ? 0x80000000 : 0x00000000); - *dest |= (((*src & 0x00f80000) << 7) | - ((*src & 0x0000f800) << 10) | - ((*src & 0x000000f8) << 13)); - src++; - dest++; - } + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = ((*src & 0xff000000) ? 0x00008000 : 0x00000000); + *dest |= (((*src & 0x00f80000) >> 9) | + ((*src & 0x0000f800) >> 6) | + ((*src & 0x000000f8) >> 3)); + src++; + *dest |= ((*src & 0xff000000) ? 0x80000000 : 0x00000000); + *dest |= (((*src & 0x00f80000) << 7) | + ((*src & 0x0000f800) << 10) | + ((*src & 0x000000f8) << 13)); + src++; + dest++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; #if 1 - mov edx, eax; - and eax, 0xff000000; // aaaa0000 00000000 00000000 00000000 - jz transparent1; - mov eax, 0x00008000; // 00000000 00000000 a0000000 00000000 + mov edx, eax; + and eax, 0xff000000; // aaaa0000 00000000 00000000 00000000 + jz transparent1; + mov eax, 0x00008000; // 00000000 00000000 a0000000 00000000 - transparent1: - mov ebx, edx; - and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 - shr ebx, 9; // 00000000 00000000 0rrrrr00 00000000 - or eax, ebx; // 00000000 00000000 arrrrr00 00000000 - mov ebx, edx; - and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 - shr ebx, 6; // 00000000 00000000 000000gg ggg00000 - or eax, ebx; // 00000000 00000000 arrrrrgg ggg00000 - and edx, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 - shr edx, 3; // 00000000 00000000 00000000 000bbbbb - or edx, eax; // 00000000 00000000 arrrrrgg gggbbbbb + transparent1: + mov ebx, edx; + and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 + shr ebx, 9; // 00000000 00000000 0rrrrr00 00000000 + or eax, ebx; // 00000000 00000000 arrrrr00 00000000 + mov ebx, edx; + and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 + shr ebx, 6; // 00000000 00000000 000000gg ggg00000 + or eax, ebx; // 00000000 00000000 arrrrrgg ggg00000 + and edx, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 + shr edx, 3; // 00000000 00000000 00000000 000bbbbb + or edx, eax; // 00000000 00000000 arrrrrgg gggbbbbb - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and eax, 0xff000000; // aaaa0000 00000000 00000000 00000000 - jz transparent2; - or edx, 0x80000000; // a0000000 00000000 arrrrrgg gggbbbbb + mov ebx, eax; + and eax, 0xff000000; // aaaa0000 00000000 00000000 00000000 + jz transparent2; + or edx, 0x80000000; // a0000000 00000000 arrrrrgg gggbbbbb - transparent2: - mov eax, ebx; - and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 - shl ebx, 7; // 0rrrrr00 00000000 00000000 00000000 - or edx, ebx; // arrrrr00 00000000 arrrrrgg gggbbbbb - mov ebx, eax; - and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 - shl ebx, 10; // 000000gg ggg00000 00000000 00000000 - or edx, ebx; // arrrrrgg ggg00000 arrrrrgg gggbbbbb - and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 - shl eax, 13; // 00000000 000bbbbb 00000000 00000000 - or edx, eax; // arrrrrgg gggbbbbb arrrrrgg gggbbbbb + transparent2: + mov eax, ebx; + and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 + shl ebx, 7; // 0rrrrr00 00000000 00000000 00000000 + or edx, ebx; // arrrrr00 00000000 arrrrrgg gggbbbbb + mov ebx, eax; + and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 + shl ebx, 10; // 000000gg ggg00000 00000000 00000000 + or edx, ebx; // arrrrrgg ggg00000 arrrrrgg gggbbbbb + and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 + shl eax, 13; // 00000000 000bbbbb 00000000 00000000 + or edx, eax; // arrrrrgg gggbbbbb arrrrrgg gggbbbbb - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; #else - mov edx, eax; - and edx, 0x01000000; // 0000000a 00000000 00000000 00000000 - shr edx, 9; // 00000000 00000000 a0000000 00000000 - mov ebx, eax; - and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 - shr ebx, 9; // 00000000 00000000 0rrrrr00 00000000 - or edx, ebx; // 00000000 00000000 arrrrr00 00000000 - mov ebx, eax; - and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 - shr ebx, 6; // 00000000 00000000 000000gg ggg00000 - or edx, ebx; // 00000000 00000000 arrrrrgg ggg00000 - and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 - shr eax, 3; // 00000000 00000000 00000000 000bbbbb - or edx, eax; // 00000000 00000000 arrrrrgg gggbbbbb + mov edx, eax; + and edx, 0x01000000; // 0000000a 00000000 00000000 00000000 + shr edx, 9; // 00000000 00000000 a0000000 00000000 + mov ebx, eax; + and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 + shr ebx, 9; // 00000000 00000000 0rrrrr00 00000000 + or edx, ebx; // 00000000 00000000 arrrrr00 00000000 + mov ebx, eax; + and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 + shr ebx, 6; // 00000000 00000000 000000gg ggg00000 + or edx, ebx; // 00000000 00000000 arrrrrgg ggg00000 + and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 + shr eax, 3; // 00000000 00000000 00000000 000bbbbb + or edx, eax; // 00000000 00000000 arrrrrgg gggbbbbb - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and ebx, 0x80000000; // a0000000 00000000 00000000 00000000 - or edx, ebx; // a0000000 00000000 arrrrrgg gggbbbbb - mov ebx, eax; - and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 - shl ebx, 7; // 0rrrrr00 00000000 00000000 00000000 - or edx, ebx; // arrrrr00 00000000 arrrrrgg gggbbbbb - mov ebx, eax; - and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 - shl ebx, 10; // 000000gg ggg00000 00000000 00000000 - or edx, ebx; // arrrrrgg ggg00000 arrrrrgg gggbbbbb - and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 - shl eax, 13; // 00000000 000bbbbb 00000000 00000000 - or edx, eax; // arrrrrgg gggbbbbb arrrrrgg gggbbbbb + mov ebx, eax; + and ebx, 0x80000000; // a0000000 00000000 00000000 00000000 + or edx, ebx; // a0000000 00000000 arrrrrgg gggbbbbb + mov ebx, eax; + and ebx, 0x00f80000; // 00000000 rrrrr000 00000000 00000000 + shl ebx, 7; // 0rrrrr00 00000000 00000000 00000000 + or edx, ebx; // arrrrr00 00000000 arrrrrgg gggbbbbb + mov ebx, eax; + and ebx, 0x0000f800; // 00000000 00000000 ggggg000 00000000 + shl ebx, 10; // 000000gg ggg00000 00000000 00000000 + or edx, ebx; // arrrrrgg ggg00000 arrrrrgg gggbbbbb + and eax, 0x000000f8; // 00000000 00000000 00000000 bbbbb000 + shl eax, 13; // 00000000 000bbbbb 00000000 00000000 + or edx, eax; // arrrrrgg gggbbbbb arrrrrgg gggbbbbb - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; #endif - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -770,80 +761,80 @@ void TxQuantize::ARGB8888_ARGB4444(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (((*src & 0xf0000000) >> 16) | - ((*src & 0x00f00000) >> 12) | - ((*src & 0x0000f000) >> 8) | - ((*src & 0x000000f0) >> 4)); - src++; - *dest |= ((*src & 0xf0000000) | - ((*src & 0x00f00000) << 4) | - ((*src & 0x0000f000) << 8) | - ((*src & 0x000000f0) << 12)); - src++; - dest++; - } + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (((*src & 0xf0000000) >> 16) | + ((*src & 0x00f00000) >> 12) | + ((*src & 0x0000f000) >> 8) | + ((*src & 0x000000f0) >> 4)); + src++; + *dest |= ((*src & 0xf0000000) | + ((*src & 0x00f00000) << 4) | + ((*src & 0x0000f000) << 8) | + ((*src & 0x000000f0) << 12)); + src++; + dest++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - mov edx, eax; - and edx, 0xf0000000; // aaaa0000 00000000 00000000 00000000 - shr edx, 16; // 00000000 00000000 aaaa0000 00000000 - mov ebx, eax; - and ebx, 0x00f00000; // 00000000 rrrr0000 00000000 00000000 - shr ebx, 12; // 00000000 00000000 0000rrrr 00000000 - or edx, ebx; // 00000000 00000000 aaaarrrr 00000000 - mov ebx, eax; - and ebx, 0x0000f000; // 00000000 00000000 gggg0000 00000000 - shr ebx, 8; // 00000000 00000000 00000000 gggg0000 - or edx, ebx; // 00000000 00000000 aaaarrrr gggg0000 - and eax, 0x000000f0; // 00000000 00000000 00000000 bbbb0000 - shr eax, 4; // 00000000 00000000 00000000 0000bbbb - or edx, eax; // 00000000 00000000 aaaarrrr ggggbbbb + mov edx, eax; + and edx, 0xf0000000; // aaaa0000 00000000 00000000 00000000 + shr edx, 16; // 00000000 00000000 aaaa0000 00000000 + mov ebx, eax; + and ebx, 0x00f00000; // 00000000 rrrr0000 00000000 00000000 + shr ebx, 12; // 00000000 00000000 0000rrrr 00000000 + or edx, ebx; // 00000000 00000000 aaaarrrr 00000000 + mov ebx, eax; + and ebx, 0x0000f000; // 00000000 00000000 gggg0000 00000000 + shr ebx, 8; // 00000000 00000000 00000000 gggg0000 + or edx, ebx; // 00000000 00000000 aaaarrrr gggg0000 + and eax, 0x000000f0; // 00000000 00000000 00000000 bbbb0000 + shr eax, 4; // 00000000 00000000 00000000 0000bbbb + or edx, eax; // 00000000 00000000 aaaarrrr ggggbbbb - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and ebx, 0xf0000000; // aaaa0000 00000000 00000000 00000000 - or edx, ebx; // aaaa0000 00000000 aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x00f00000; // 00000000 rrrr0000 00000000 00000000 - shl ebx, 4; // 0000rrrr 00000000 00000000 00000000 - or edx, ebx; // aaaarrrr 00000000 aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x0000f000; // 00000000 00000000 gggg0000 00000000 - shl ebx, 8; // 00000000 gggg0000 00000000 00000000 - or edx, ebx; // aaaarrrr gggg0000 aaaarrrr ggggbbbb - and eax, 0x000000f0; // 00000000 00000000 00000000 bbbb0000 - shl eax, 12; // 00000000 0000bbbb 00000000 00000000 - or edx, eax; // arrrrrgg ggggbbbb aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0xf0000000; // aaaa0000 00000000 00000000 00000000 + or edx, ebx; // aaaa0000 00000000 aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x00f00000; // 00000000 rrrr0000 00000000 00000000 + shl ebx, 4; // 0000rrrr 00000000 00000000 00000000 + or edx, ebx; // aaaarrrr 00000000 aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x0000f000; // 00000000 00000000 gggg0000 00000000 + shl ebx, 8; // 00000000 gggg0000 00000000 00000000 + or edx, ebx; // aaaarrrr gggg0000 aaaarrrr ggggbbbb + and eax, 0x000000f0; // 00000000 00000000 00000000 bbbb0000 + shl eax, 12; // 00000000 0000bbbb 00000000 00000000 + or edx, eax; // arrrrrgg ggggbbbb aaaarrrr ggggbbbb - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -851,73 +842,73 @@ void TxQuantize::ARGB8888_RGB565(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (((*src & 0x000000f8) >> 3) | - ((*src & 0x0000fc00) >> 5) | - ((*src & 0x00f80000) >> 8)); - src++; - *dest |= (((*src & 0x000000f8) << 13) | - ((*src & 0x0000fc00) << 11) | - ((*src & 0x00f80000) << 8)); - src++; - dest++; - } + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (((*src & 0x000000f8) >> 3) | + ((*src & 0x0000fc00) >> 5) | + ((*src & 0x00f80000) >> 8)); + src++; + *dest |= (((*src & 0x000000f8) << 13) | + ((*src & 0x0000fc00) << 11) | + ((*src & 0x00f80000) << 8)); + src++; + dest++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - mov edx, eax; - and edx, 0x000000F8; // 00000000 00000000 00000000 bbbbb000 - shr edx, 3; // 00000000 00000000 00000000 000bbbbb - mov ebx, eax; - and ebx, 0x0000FC00; // 00000000 00000000 gggggg00 00000000 - shr ebx, 5; // 00000000 00000000 00000ggg ggg00000 - or edx, ebx; // 00000000 00000000 00000ggg gggbbbbb - mov ebx, eax; - and ebx, 0x00F80000; // 00000000 rrrrr000 00000000 00000000 - shr ebx, 8; // 00000000 00000000 rrrrr000 00000000 - or edx, ebx; // 00000000 00000000 rrrrrggg gggbbbbb + mov edx, eax; + and edx, 0x000000F8; // 00000000 00000000 00000000 bbbbb000 + shr edx, 3; // 00000000 00000000 00000000 000bbbbb + mov ebx, eax; + and ebx, 0x0000FC00; // 00000000 00000000 gggggg00 00000000 + shr ebx, 5; // 00000000 00000000 00000ggg ggg00000 + or edx, ebx; // 00000000 00000000 00000ggg gggbbbbb + mov ebx, eax; + and ebx, 0x00F80000; // 00000000 rrrrr000 00000000 00000000 + shr ebx, 8; // 00000000 00000000 rrrrr000 00000000 + or edx, ebx; // 00000000 00000000 rrrrrggg gggbbbbb - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and ebx, 0x000000F8; // 00000000 00000000 00000000 bbbbb000 - shl ebx, 13; // 00000000 000bbbbb 00000000 00000000 - or edx, ebx; // 00000000 000bbbbb rrrrrggg gggbbbbb - mov ebx, eax; - and ebx, 0x0000FC00; // 00000000 00000000 gggggg00 00000000 - shl ebx, 11; // 00000ggg ggg00000 00000000 00000000 - or edx, ebx; // 00000ggg gggbbbbb rrrrrggg gggbbbbb - mov ebx, eax; - and ebx, 0x00F80000; // 00000000 rrrrr000 00000000 00000000 - shl ebx, 8; // rrrrr000 00000000 00000000 00000000 - or edx, ebx; // rrrrrggg gggbbbbb rrrrrggg gggbbbbb + mov ebx, eax; + and ebx, 0x000000F8; // 00000000 00000000 00000000 bbbbb000 + shl ebx, 13; // 00000000 000bbbbb 00000000 00000000 + or edx, ebx; // 00000000 000bbbbb rrrrrggg gggbbbbb + mov ebx, eax; + and ebx, 0x0000FC00; // 00000000 00000000 gggggg00 00000000 + shl ebx, 11; // 00000ggg ggg00000 00000000 00000000 + or edx, ebx; // 00000ggg gggbbbbb rrrrrggg gggbbbbb + mov ebx, eax; + and ebx, 0x00F80000; // 00000000 rrrrr000 00000000 00000000 + shl ebx, 8; // rrrrr000 00000000 00000000 00000000 + or edx, ebx; // rrrrrggg gggbbbbb rrrrrggg gggbbbbb - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -925,119 +916,119 @@ void TxQuantize::ARGB8888_A8(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 2; - int i; - for (i = 0; i < siz; i++) { - *dest = (*src & 0x0000ff00) >> 8; - src++; - *dest |= (*src & 0x0000ff00); - src++; - *dest |= ((*src & 0x0000ff00) << 8); - src++; - *dest |= ((*src & 0x0000ff00) << 16); - src++; - dest++; - } + int siz = (width * height) >> 2; + int i; + for (i = 0; i < siz; i++) { + *dest = (*src & 0x0000ff00) >> 8; + src++; + *dest |= (*src & 0x0000ff00); + src++; + *dest |= ((*src & 0x0000ff00) << 8); + src++; + *dest |= ((*src & 0x0000ff00) << 16); + src++; + dest++; + } #else - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; #if 0 - mov edx, eax; // we'll use A comp for every pixel - and edx, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - shr edx, 24; // 00000000 00000000 00000000 aaaaaaaa + mov edx, eax; // we'll use A comp for every pixel + and edx, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + shr edx, 24; // 00000000 00000000 00000000 aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - shr eax, 16; // 00000000 00000000 aaaaaaaa 00000000 - or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa + and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + shr eax, 16; // 00000000 00000000 aaaaaaaa 00000000 + or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - shr eax, 8; // 00000000 aaaaaaaa 00000000 00000000 - or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + shr eax, 8; // 00000000 aaaaaaaa 00000000 00000000 + or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa #endif #if 1 - mov edx, eax; // we'll use G comp for every pixel - and edx, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 - shr edx, 8; // 00000000 00000000 00000000 aaaaaaaa + mov edx, eax; // we'll use G comp for every pixel + and edx, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 + shr edx, 8; // 00000000 00000000 00000000 aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 - or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa + and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 + or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 - shl eax, 8; // 00000000 aaaaaaaa 00000000 00000000 - or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 + shl eax, 8; // 00000000 aaaaaaaa 00000000 00000000 + or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 - shl eax, 16; // aaaaaaaa 00000000 00000000 00000000 - or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 + shl eax, 16; // aaaaaaaa 00000000 00000000 00000000 + or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa #endif #if 0 - mov edx, eax; - and edx, 0x000000FF; // 00000000 00000000 00000000 aaaaaaaa + mov edx, eax; + and edx, 0x000000FF; // 00000000 00000000 00000000 aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 - or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa + and eax, 0x0000FF00; // 00000000 00000000 aaaaaaaa 00000000 + or edx, eax; // 00000000 00000000 aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0x00FF0000; // 00000000 aaaaaaaa 00000000 00000000 - or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0x00FF0000; // 00000000 aaaaaaaa 00000000 00000000 + or edx, eax; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa + and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + or edx, eax; // aaaaaaaa aaaaaaaa aaaaaaaa aaaaaaaa #endif - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -1045,85 +1036,85 @@ void TxQuantize::ARGB8888_AI44(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 2; - int i; - for (i = 0; i < siz; i++) { - *dest = (((*src & 0xf0000000) >> 24) | ((*src & 0x0000f000) >> 12)); - src++; - *dest |= (((*src & 0xf0000000) >> 16) | ((*src & 0x0000f000) >> 4)); - src++; - *dest |= (((*src & 0xf0000000) >> 8) | ((*src & 0x0000f000) << 4)); - src++; - *dest |= ((*src & 0xf0000000) | ((*src & 0x0000f000) << 12)); - src++; - dest++; - } + int siz = (width * height) >> 2; + int i; + for (i = 0; i < siz; i++) { + *dest = (((*src & 0xf0000000) >> 24) | ((*src & 0x0000f000) >> 12)); + src++; + *dest |= (((*src & 0xf0000000) >> 16) | ((*src & 0x0000f000) >> 4)); + src++; + *dest |= (((*src & 0xf0000000) >> 8) | ((*src & 0x0000f000) << 4)); + src++; + *dest |= ((*src & 0xf0000000) | ((*src & 0x0000f000) << 12)); + src++; + dest++; + } #else - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - mov edx, eax; // use A and G comps MSB - and edx, 0xF0000000; // aaaa0000 00000000 00000000 00000000 - mov ebx, eax; - shr edx, 24; // 00000000 00000000 00000000 aaaa0000 - and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 - shr ebx, 12; // 00000000 00000000 00000000 0000iiii - or edx, ebx; // 00000000 00000000 00000000 aaaaiiii + mov edx, eax; // use A and G comps MSB + and edx, 0xF0000000; // aaaa0000 00000000 00000000 00000000 + mov ebx, eax; + shr edx, 24; // 00000000 00000000 00000000 aaaa0000 + and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 + shr ebx, 12; // 00000000 00000000 00000000 0000iiii + or edx, ebx; // 00000000 00000000 00000000 aaaaiiii - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 - shr eax, 16; // 00000000 00000000 aaaa0000 00000000 - and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 - shr ebx, 4; // 00000000 00000000 0000iiii 00000000 - or eax, ebx; // 00000000 00000000 aaaaiiii 00000000 - or edx, eax; // 00000000 00000000 aaaaiiii aaaaiiii + mov ebx, eax; + and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 + shr eax, 16; // 00000000 00000000 aaaa0000 00000000 + and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 + shr ebx, 4; // 00000000 00000000 0000iiii 00000000 + or eax, ebx; // 00000000 00000000 aaaaiiii 00000000 + or edx, eax; // 00000000 00000000 aaaaiiii aaaaiiii - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 - shr eax, 8; // 00000000 aaaa0000 00000000 00000000 - and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 - shl ebx, 4; // 00000000 0000iiii 00000000 00000000 - or eax, ebx; // 00000000 aaaaiiii 00000000 00000000 - or edx, eax; // 00000000 aaaaiiii aaaaiiii aaaaiiii + mov ebx, eax; + and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 + shr eax, 8; // 00000000 aaaa0000 00000000 00000000 + and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 + shl ebx, 4; // 00000000 0000iiii 00000000 00000000 + or eax, ebx; // 00000000 aaaaiiii 00000000 00000000 + or edx, eax; // 00000000 aaaaiiii aaaaiiii aaaaiiii - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 - and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 - shl ebx, 12; // 0000iiii 00000000 00000000 00000000 - or eax, ebx; // aaaaiiii 00000000 00000000 00000000 - or edx, eax; // aaaaiiii aaaaiiii aaaaiiii aaaaiiii + mov ebx, eax; + and eax, 0xF0000000; // aaaa0000 00000000 00000000 00000000 + and ebx, 0x0000F000; // 00000000 00000000 iiii0000 00000000 + shl ebx, 12; // 0000iiii 00000000 00000000 00000000 + or eax, ebx; // aaaaiiii 00000000 00000000 00000000 + or edx, eax; // aaaaiiii aaaaiiii aaaaiiii aaaaiiii - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -1131,59 +1122,59 @@ void TxQuantize::ARGB8888_AI88(uint32* src, uint32* dest, int width, int height) { #if 1 - int siz = (width * height) >> 1; - int i; - for (i = 0; i < siz; i++) { - *dest = (((*src & 0xff000000) >> 16) | ((*src & 0x0000ff00) >> 8)); - src++; - *dest |= ((*src & 0xff000000) | ((*src & 0x0000ff00) << 8)); - src++; - dest++; - } + int siz = (width * height) >> 1; + int i; + for (i = 0; i < siz; i++) { + *dest = (((*src & 0xff000000) >> 16) | ((*src & 0x0000ff00) >> 8)); + src++; + *dest |= ((*src & 0xff000000) | ((*src & 0x0000ff00) << 8)); + src++; + dest++; + } #else - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - mov edx, eax; - and edx, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - mov ebx, eax; - shr edx, 16; // 00000000 00000000 aaaaaaaa 00000000 - and ebx, 0x0000FF00; // 00000000 00000000 iiiiiiii 00000000 - shr ebx, 8; // 00000000 00000000 00000000 iiiiiiii - or edx, ebx; // 00000000 00000000 aaaaaaaa iiiiiiii + mov edx, eax; + and edx, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + mov ebx, eax; + shr edx, 16; // 00000000 00000000 aaaaaaaa 00000000 + and ebx, 0x0000FF00; // 00000000 00000000 iiiiiiii 00000000 + shr ebx, 8; // 00000000 00000000 00000000 iiiiiiii + or edx, ebx; // 00000000 00000000 aaaaaaaa iiiiiiii - mov eax, dword ptr [esi]; - add esi, 4; + mov eax, dword ptr[esi]; + add esi, 4; - mov ebx, eax; - and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 - and ebx, 0x0000FF00; // 00000000 00000000 iiiiiiii 00000000 - shl ebx, 8; // 00000000 iiiiiiii 00000000 00000000 - or eax, ebx; // aaaaaaaa iiiiiiii 00000000 00000000 - or edx, eax; // aaaaaaaa iiiiiiii aaaaaaaa iiiiiiii + mov ebx, eax; + and eax, 0xFF000000; // aaaaaaaa 00000000 00000000 00000000 + and ebx, 0x0000FF00; // 00000000 00000000 iiiiiiii 00000000 + shl ebx, 8; // 00000000 iiiiiiii 00000000 00000000 + or eax, ebx; // aaaaaaaa iiiiiiii 00000000 00000000 + or edx, eax; // aaaaaaaa iiiiiiii aaaaaaaa iiiiiiii - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } @@ -1194,1072 +1185,1075 @@ TxQuantize::ARGB8888_AI88(uint32* src, uint32* dest, int width, int height) void TxQuantize::ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + /* Floyd-Steinberg error-diffusion halftoning */ - int i, x, y; - int qr, qg, qb; /* quantized incoming values */ - int ir, ig, ib; /* incoming values */ - int t; - int *errR = new int[width]; - int *errG = new int[width]; - int *errB = new int[width]; + int i, x, y; + int qr, qg, qb; /* quantized incoming values */ + int ir, ig, ib; /* incoming values */ + int t; + int *errR = new int[width]; + int *errG = new int[width]; + int *errB = new int[width]; - uint16 *dest = (uint16 *)dst; + uint16 *dest = (uint16 *)dst; - for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = 0; + for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = 0; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - /* incoming pixel values */ - ir = ((*src >> 16) & 0xFF) * 10000; - ig = ((*src >> 8) & 0xFF) * 10000; - ib = ((*src ) & 0xFF) * 10000; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + /* incoming pixel values */ + ir = ((*src >> 16) & 0xFF) * 10000; + ig = ((*src >> 8) & 0xFF) * 10000; + ib = ((*src) & 0xFF) * 10000; - if (x == 0) qr = qg = qb = 0; + if (x == 0) qr = qg = qb = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ - ir += errR[x] + qr * 4375 / 10000; - ig += errG[x] + qg * 4375 / 10000; - ib += errB[x] + qb * 4375 / 10000; + /* quantize pixel values. + * qr * 0.4375 is the error from the pixel to the left, + * errR is the error from the pixel to the top, top left, and top right */ + /* qr * 0.4375 is the error distribution to the EAST in + * the previous loop */ + ir += errR[x] + qr * 4375 / 10000; + ig += errG[x] + qg * 4375 / 10000; + ib += errB[x] + qb * 4375 / 10000; - /* error distribution to the SOUTH-EAST in the previous loop - * can't calculate in the previous loop because it steps on - * the above quantization */ - errR[x] = qr * 625 / 10000; - errG[x] = qg * 625 / 10000; - errB[x] = qb * 625 / 10000; + /* error distribution to the SOUTH-EAST in the previous loop + * can't calculate in the previous loop because it steps on + * the above quantization */ + errR[x] = qr * 625 / 10000; + errG[x] = qg * 625 / 10000; + errB[x] = qb * 625 / 10000; - qr = ir; - qg = ig; - qb = ib; + qr = ir; + qg = ig; + qb = ib; - /* clamp */ - if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; - if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; - if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; + /* clamp */ + if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; + if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; + if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; - /* convert to RGB565 */ - qr = qr * 0x1F / 2550000; - qg = qg * 0x3F / 2550000; - qb = qb * 0x1F / 2550000; + /* convert to RGB565 */ + qr = qr * 0x1F / 2550000; + qg = qg * 0x3F / 2550000; + qb = qb * 0x1F / 2550000; - /* this is the dithered pixel */ - t = (qr << 11) | (qg << 5) | qb; + /* this is the dithered pixel */ + t = (qr << 11) | (qg << 5) | qb; - /* compute the errors */ - qr = ((qr << 3) | (qr >> 2)) * 10000; - qg = ((qg << 2) | (qg >> 4)) * 10000; - qb = ((qb << 3) | (qb >> 2)) * 10000; - qr = ir - qr; - qg = ig - qg; - qb = ib - qb; + /* compute the errors */ + qr = ((qr << 3) | (qr >> 2)) * 10000; + qg = ((qg << 2) | (qg >> 4)) * 10000; + qb = ((qb << 3) | (qb >> 2)) * 10000; + qr = ir - qr; + qg = ig - qg; + qb = ib - qb; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ - if (x > 1) { - errR[x - 1] += qr * 1875 / 10000; - errG[x - 1] += qg * 1875 / 10000; - errB[x - 1] += qb * 1875 / 10000; - } + /* compute the error distributions */ + /* Floyd-Steinberg filter + * 7/16 (=0.4375) to the EAST + * 5/16 (=0.3125) to the SOUTH + * 1/16 (=0.0625) to the SOUTH-EAST + * 3/16 (=0.1875) to the SOUTH-WEST + * + * x 7/16 + * 3/16 5/16 1/16 + */ + /* SOUTH-WEST */ + if (x > 1) { + errR[x - 1] += qr * 1875 / 10000; + errG[x - 1] += qg * 1875 / 10000; + errB[x - 1] += qb * 1875 / 10000; + } - /* SOUTH */ - errR[x] += qr * 3125 / 10000; - errG[x] += qg * 3125 / 10000; - errB[x] += qb * 3125 / 10000; + /* SOUTH */ + errR[x] += qr * 3125 / 10000; + errG[x] += qg * 3125 / 10000; + errB[x] += qb * 3125 / 10000; - *dest = (t & 0xFFFF); + *dest = (t & 0xFFFF); - dest++; - src++; + dest++; + src++; + } } - } - delete [] errR; - delete [] errG; - delete [] errB; + delete[] errR; + delete[] errG; + delete[] errB; } - void TxQuantize::ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + /* Floyd-Steinberg error-diffusion halftoning */ - int i, x, y; - int qr, qg, qb; /* quantized incoming values */ - int ir, ig, ib; /* incoming values */ - int t; - int *errR = new int[width]; - int *errG = new int[width]; - int *errB = new int[width]; + int i, x, y; + int qr, qg, qb; /* quantized incoming values */ + int ir, ig, ib; /* incoming values */ + int t; + int *errR = new int[width]; + int *errG = new int[width]; + int *errB = new int[width]; - uint16 *dest = (uint16 *)dst; + uint16 *dest = (uint16 *)dst; - for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = 0; + for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = 0; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - /* incoming pixel values */ - ir = ((*src >> 16) & 0xFF) * 10000; - ig = ((*src >> 8) & 0xFF) * 10000; - ib = ((*src ) & 0xFF) * 10000; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + /* incoming pixel values */ + ir = ((*src >> 16) & 0xFF) * 10000; + ig = ((*src >> 8) & 0xFF) * 10000; + ib = ((*src) & 0xFF) * 10000; - if (x == 0) qr = qg = qb = 0; + if (x == 0) qr = qg = qb = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ - ir += errR[x] + qr * 4375 / 10000; - ig += errG[x] + qg * 4375 / 10000; - ib += errB[x] + qb * 4375 / 10000; + /* quantize pixel values. + * qr * 0.4375 is the error from the pixel to the left, + * errR is the error from the pixel to the top, top left, and top right */ + /* qr * 0.4375 is the error distribution to the EAST in + * the previous loop */ + ir += errR[x] + qr * 4375 / 10000; + ig += errG[x] + qg * 4375 / 10000; + ib += errB[x] + qb * 4375 / 10000; - /* error distribution to the SOUTH-EAST of the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ - errR[x] = qr * 625 / 10000; - errG[x] = qg * 625 / 10000; - errB[x] = qb * 625 / 10000; + /* error distribution to the SOUTH-EAST of the previous loop. + * cannot calculate in the previous loop because it steps on + * the above quantization */ + errR[x] = qr * 625 / 10000; + errG[x] = qg * 625 / 10000; + errB[x] = qb * 625 / 10000; - qr = ir; - qg = ig; - qb = ib; + qr = ir; + qg = ig; + qb = ib; - /* clamp */ - if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; - if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; - if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; + /* clamp */ + if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; + if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; + if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; - /* convert to RGB555 */ - qr = qr * 0x1F / 2550000; - qg = qg * 0x1F / 2550000; - qb = qb * 0x1F / 2550000; + /* convert to RGB555 */ + qr = qr * 0x1F / 2550000; + qg = qg * 0x1F / 2550000; + qb = qb * 0x1F / 2550000; - /* this is the dithered pixel */ - t = (qr << 10) | (qg << 5) | qb; - t |= ((*src >> 24) ? 0x8000 : 0); + /* this is the dithered pixel */ + t = (qr << 10) | (qg << 5) | qb; + t |= ((*src >> 24) ? 0x8000 : 0); - /* compute the errors */ - qr = ((qr << 3) | (qr >> 2)) * 10000; - qg = ((qg << 3) | (qg >> 2)) * 10000; - qb = ((qb << 3) | (qb >> 2)) * 10000; - qr = ir - qr; - qg = ig - qg; - qb = ib - qb; + /* compute the errors */ + qr = ((qr << 3) | (qr >> 2)) * 10000; + qg = ((qg << 3) | (qg >> 2)) * 10000; + qb = ((qb << 3) | (qb >> 2)) * 10000; + qr = ir - qr; + qg = ig - qg; + qb = ib - qb; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ - if (x > 1) { - errR[x - 1] += qr * 1875 / 10000; - errG[x - 1] += qg * 1875 / 10000; - errB[x - 1] += qb * 1875 / 10000; - } + /* compute the error distributions */ + /* Floyd-Steinberg filter + * 7/16 (=0.4375) to the EAST + * 5/16 (=0.3125) to the SOUTH + * 1/16 (=0.0625) to the SOUTH-EAST + * 3/16 (=0.1875) to the SOUTH-WEST + * + * x 7/16 + * 3/16 5/16 1/16 + */ + /* SOUTH-WEST */ + if (x > 1) { + errR[x - 1] += qr * 1875 / 10000; + errG[x - 1] += qg * 1875 / 10000; + errB[x - 1] += qb * 1875 / 10000; + } - /* SOUTH */ - errR[x] += qr * 3125 / 10000; - errG[x] += qg * 3125 / 10000; - errB[x] += qb * 3125 / 10000; + /* SOUTH */ + errR[x] += qr * 3125 / 10000; + errG[x] += qg * 3125 / 10000; + errB[x] += qb * 3125 / 10000; - *dest = (t & 0xFFFF); + *dest = (t & 0xFFFF); - dest++; - src++; + dest++; + src++; + } } - } - delete [] errR; - delete [] errG; - delete [] errB; + delete[] errR; + delete[] errG; + delete[] errB; } void TxQuantize::ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + /* Floyd-Steinberg error-diffusion halftoning */ - /* NOTE: alpha dithering looks better for alpha gradients, but are prone - * to producing noisy speckles for constant or step level alpha. Output - * results should always be checked. - */ - boolean ditherAlpha = 0; + /* NOTE: alpha dithering looks better for alpha gradients, but are prone + * to producing noisy speckles for constant or step level alpha. Output + * results should always be checked. + */ + bool ditherAlpha = 0; - int i, x, y; - int qr, qg, qb, qa; /* quantized incoming values */ - int ir, ig, ib, ia; /* incoming values */ - int t; - int *errR = new int[width]; - int *errG = new int[width]; - int *errB = new int[width]; - int *errA = new int[width]; + int i, x, y; + int qr, qg, qb, qa; /* quantized incoming values */ + int ir, ig, ib, ia; /* incoming values */ + int t; + int *errR = new int[width]; + int *errG = new int[width]; + int *errB = new int[width]; + int *errA = new int[width]; - uint16 *dest = (uint16 *)dst; + uint16 *dest = (uint16 *)dst; - for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = errA[i] = 0; + for (i = 0; i < width; i++) errR[i] = errG[i] = errB[i] = errA[i] = 0; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - /* incoming pixel values */ - ir = ((*src >> 16) & 0xFF) * 10000; - ig = ((*src >> 8) & 0xFF) * 10000; - ib = ((*src ) & 0xFF) * 10000; - ia = ((*src >> 24) & 0xFF) * 10000; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + /* incoming pixel values */ + ir = ((*src >> 16) & 0xFF) * 10000; + ig = ((*src >> 8) & 0xFF) * 10000; + ib = ((*src) & 0xFF) * 10000; + ia = ((*src >> 24) & 0xFF) * 10000; - if (x == 0) qr = qg = qb = qa = 0; + if (x == 0) qr = qg = qb = qa = 0; - /* quantize pixel values. - * qr * 0.4375 is the error from the pixel to the left, - * errR is the error from the pixel to the top, top left, and top right */ - /* qr * 0.4375 is the error distribution to the EAST in - * the previous loop */ - ir += errR[x] + qr * 4375 / 10000; - ig += errG[x] + qg * 4375 / 10000; - ib += errB[x] + qb * 4375 / 10000; - ia += errA[x] + qa * 4375 / 10000; + /* quantize pixel values. + * qr * 0.4375 is the error from the pixel to the left, + * errR is the error from the pixel to the top, top left, and top right */ + /* qr * 0.4375 is the error distribution to the EAST in + * the previous loop */ + ir += errR[x] + qr * 4375 / 10000; + ig += errG[x] + qg * 4375 / 10000; + ib += errB[x] + qb * 4375 / 10000; + ia += errA[x] + qa * 4375 / 10000; - /* error distribution to the SOUTH-EAST of the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ - errR[x] = qr * 625 / 10000; - errG[x] = qg * 625 / 10000; - errB[x] = qb * 625 / 10000; - errA[x] = qa * 625 / 10000; + /* error distribution to the SOUTH-EAST of the previous loop. + * cannot calculate in the previous loop because it steps on + * the above quantization */ + errR[x] = qr * 625 / 10000; + errG[x] = qg * 625 / 10000; + errB[x] = qb * 625 / 10000; + errA[x] = qa * 625 / 10000; - qr = ir; - qg = ig; - qb = ib; - qa = ia; + qr = ir; + qg = ig; + qb = ib; + qa = ia; - /* clamp */ - if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; - if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; - if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; - if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; + /* clamp */ + if (qr < 0) qr = 0; else if (qr > 2550000) qr = 2550000; + if (qg < 0) qg = 0; else if (qg > 2550000) qg = 2550000; + if (qb < 0) qb = 0; else if (qb > 2550000) qb = 2550000; + if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; - /* convert to RGB444 */ - qr = qr * 0xF / 2550000; - qg = qg * 0xF / 2550000; - qb = qb * 0xF / 2550000; - qa = qa * 0xF / 2550000; + /* convert to RGB444 */ + qr = qr * 0xF / 2550000; + qg = qg * 0xF / 2550000; + qb = qb * 0xF / 2550000; + qa = qa * 0xF / 2550000; - /* this is the value to be returned */ - if (ditherAlpha) { - t = (qa << 12) | (qr << 8) | (qg << 4) | qb; - } else { - t = (qr << 8) | (qg << 4) | qb; - t |= (*src >> 16) & 0xF000; - } + /* this is the value to be returned */ + if (ditherAlpha) { + t = (qa << 12) | (qr << 8) | (qg << 4) | qb; + } + else { + t = (qr << 8) | (qg << 4) | qb; + t |= (*src >> 16) & 0xF000; + } - /* compute the errors */ - qr = ((qr << 4) | qr) * 10000; - qg = ((qg << 4) | qg) * 10000; - qb = ((qb << 4) | qb) * 10000; - qa = ((qa << 4) | qa) * 10000; - qr = ir - qr; - qg = ig - qg; - qb = ib - qb; - qa = ia - qa; + /* compute the errors */ + qr = ((qr << 4) | qr) * 10000; + qg = ((qg << 4) | qg) * 10000; + qb = ((qb << 4) | qb) * 10000; + qa = ((qa << 4) | qa) * 10000; + qr = ir - qr; + qg = ig - qg; + qb = ib - qb; + qa = ia - qa; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ - if (x > 1) { - errR[x - 1] += qr * 1875 / 10000; - errG[x - 1] += qg * 1875 / 10000; - errB[x - 1] += qb * 1875 / 10000; - errA[x - 1] += qa * 1875 / 10000; - } + /* compute the error distributions */ + /* Floyd-Steinberg filter + * 7/16 (=0.4375) to the EAST + * 5/16 (=0.3125) to the SOUTH + * 1/16 (=0.0625) to the SOUTH-EAST + * 3/16 (=0.1875) to the SOUTH-WEST + * + * x 7/16 + * 3/16 5/16 1/16 + */ + /* SOUTH-WEST */ + if (x > 1) { + errR[x - 1] += qr * 1875 / 10000; + errG[x - 1] += qg * 1875 / 10000; + errB[x - 1] += qb * 1875 / 10000; + errA[x - 1] += qa * 1875 / 10000; + } - /* SOUTH */ - errR[x] += qr * 3125 / 10000; - errG[x] += qg * 3125 / 10000; - errB[x] += qb * 3125 / 10000; - errA[x] += qa * 3125 / 10000; + /* SOUTH */ + errR[x] += qr * 3125 / 10000; + errG[x] += qg * 3125 / 10000; + errB[x] += qb * 3125 / 10000; + errA[x] += qa * 3125 / 10000; - *dest = (t & 0xFFFF); + *dest = (t & 0xFFFF); - dest++; - src++; + dest++; + src++; + } } - } - delete [] errR; - delete [] errG; - delete [] errB; - delete [] errA; + delete[] errR; + delete[] errG; + delete[] errB; + delete[] errA; } void TxQuantize::ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height) { - /* Floyd-Steinberg error-diffusion halftoning */ + /* Floyd-Steinberg error-diffusion halftoning */ - /* NOTE: alpha dithering looks better for alpha gradients, but are prone - * to producing noisy speckles for constant or step level alpha. Output - * results should always be checked. - */ - boolean ditherAlpha = 0; + /* NOTE: alpha dithering looks better for alpha gradients, but are prone + * to producing noisy speckles for constant or step level alpha. Output + * results should always be checked. + */ + bool ditherAlpha = 0; - int i, x, y; - int qi, qa; /* quantized incoming values */ - int ii, ia; /* incoming values */ - int t; - int *errI = new int[width]; - int *errA = new int[width]; + int i, x, y; + int qi, qa; /* quantized incoming values */ + int ii, ia; /* incoming values */ + int t; + int *errI = new int[width]; + int *errA = new int[width]; - uint8 *dest = (uint8 *)dst; + uint8 *dest = (uint8 *)dst; - for (i = 0; i < width; i++) errI[i] = errA[i] = 0; + for (i = 0; i < width; i++) errI[i] = errA[i] = 0; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 */ - ii = ((*src >> 16) & 0xFF) * 2990 + - ((*src >> 8) & 0xFF) * 5870 + - ((*src ) & 0xFF) * 1140; - ia = ((*src >> 24) & 0xFF) * 10000; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 */ + ii = ((*src >> 16) & 0xFF) * 2990 + + ((*src >> 8) & 0xFF) * 5870 + + ((*src) & 0xFF) * 1140; + ia = ((*src >> 24) & 0xFF) * 10000; - if (x == 0) qi = qa = 0; + if (x == 0) qi = qa = 0; - /* quantize pixel values. - * qi * 0.4375 is the error from the pixel to the left, - * errI is the error from the pixel to the top, top left, and top right */ - /* qi * 0.4375 is the error distrtibution to the EAST in - * the previous loop */ - ii += errI[x] + qi * 4375 / 10000; - ia += errA[x] + qa * 4375 / 10000; + /* quantize pixel values. + * qi * 0.4375 is the error from the pixel to the left, + * errI is the error from the pixel to the top, top left, and top right */ + /* qi * 0.4375 is the error distrtibution to the EAST in + * the previous loop */ + ii += errI[x] + qi * 4375 / 10000; + ia += errA[x] + qa * 4375 / 10000; - /* error distribution to the SOUTH-EAST in the previous loop. - * cannot calculate in the previous loop because it steps on - * the above quantization */ - errI[x] = qi * 625 / 10000; - errA[x] = qa * 625 / 10000; + /* error distribution to the SOUTH-EAST in the previous loop. + * cannot calculate in the previous loop because it steps on + * the above quantization */ + errI[x] = qi * 625 / 10000; + errA[x] = qa * 625 / 10000; - qi = ii; - qa = ia; + qi = ii; + qa = ia; - /* clamp */ - if (qi < 0) qi = 0; else if (qi > 2550000) qi = 2550000; - if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; + /* clamp */ + if (qi < 0) qi = 0; else if (qi > 2550000) qi = 2550000; + if (qa < 0) qa = 0; else if (qa > 2550000) qa = 2550000; - /* convert to I4 */ - qi = qi * 0xF / 2550000; - qa = qa * 0xF / 2550000; + /* convert to I4 */ + qi = qi * 0xF / 2550000; + qa = qa * 0xF / 2550000; - /* this is the value to be returned */ - if (ditherAlpha) { - t = (qa << 4) | qi; - } else { - t = qi; - t |= ((*src >> 24) & 0xF0); - } + /* this is the value to be returned */ + if (ditherAlpha) { + t = (qa << 4) | qi; + } + else { + t = qi; + t |= ((*src >> 24) & 0xF0); + } - /* compute the errors */ - qi = ((qi << 4) | qi) * 10000; - qa = ((qa << 4) | qa) * 10000; - qi = ii - qi; - qa = ia - qa; + /* compute the errors */ + qi = ((qi << 4) | qi) * 10000; + qa = ((qa << 4) | qa) * 10000; + qi = ii - qi; + qa = ia - qa; - /* compute the error distributions */ - /* Floyd-Steinberg filter - * 7/16 (=0.4375) to the EAST - * 5/16 (=0.3125) to the SOUTH - * 1/16 (=0.0625) to the SOUTH-EAST - * 3/16 (=0.1875) to the SOUTH-WEST - * - * x 7/16 - * 3/16 5/16 1/16 - */ - /* SOUTH-WEST */ - if (x > 1) { - errI[x - 1] += qi * 1875 / 10000; - errA[x - 1] += qa * 1875 / 10000; - } + /* compute the error distributions */ + /* Floyd-Steinberg filter + * 7/16 (=0.4375) to the EAST + * 5/16 (=0.3125) to the SOUTH + * 1/16 (=0.0625) to the SOUTH-EAST + * 3/16 (=0.1875) to the SOUTH-WEST + * + * x 7/16 + * 3/16 5/16 1/16 + */ + /* SOUTH-WEST */ + if (x > 1) { + errI[x - 1] += qi * 1875 / 10000; + errA[x - 1] += qa * 1875 / 10000; + } - /* SOUTH */ - errI[x] += qi * 3125 / 10000; - errA[x] += qa * 3125 / 10000; + /* SOUTH */ + errI[x] += qi * 3125 / 10000; + errA[x] += qa * 3125 / 10000; - *dest = t & 0xFF; + *dest = t & 0xFF; - dest++; - src++; + dest++; + src++; + } } - } - delete [] errI; - delete [] errA; + delete[] errI; + delete[] errA; } void TxQuantize::ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height) { - int x, y; - uint16 *dest = (uint16 *)dst; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { + int x, y; + uint16 *dest = (uint16 *)dst; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { #if 1 - /* libpng style grayscale conversion. - * Reduce RGB files to grayscale with or without alpha - * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net - * - * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - * - * We approximate this with - * - * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - * - * which can be expressed with integers as - * - * Y = (6969 * R + 23434 * G + 2365 * B)/32768 - * - * The calculation is to be done in a linear colorspace. - */ - *dest = (((int)((((*src >> 16) & 0xFF) * 6969 + - ((*src >> 8) & 0xFF) * 23434 + - ((*src ) & 0xFF) * 2365) / 32768) & 0xFF) | - (uint16)((*src >> 16) & 0xFF00)); + /* libpng style grayscale conversion. + * Reduce RGB files to grayscale with or without alpha + * using the equation given in Poynton's ColorFAQ at + * + * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net + * + * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + * + * We approximate this with + * + * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + * + * which can be expressed with integers as + * + * Y = (6969 * R + 23434 * G + 2365 * B)/32768 + * + * The calculation is to be done in a linear colorspace. + */ + *dest = (((int)((((*src >> 16) & 0xFF) * 6969 + + ((*src >> 8) & 0xFF) * 23434 + + ((*src) & 0xFF) * 2365) / 32768) & 0xFF) | + (uint16)((*src >> 16) & 0xFF00)); #else - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 - * this is same as the standard NTSC gray scale conversion. */ - *dest = (((int)((((*src >> 16) & 0xFF) * 299 + - ((*src >> 8) & 0xFF) * 587 + - ((*src ) & 0xFF) * 114) / 1000) & 0xFF) | - (uint16)((*src >> 16) & 0xFF00)); + /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 + * this is same as the standard NTSC gray scale conversion. */ + *dest = (((int)((((*src >> 16) & 0xFF) * 299 + + ((*src >> 8) & 0xFF) * 587 + + ((*src) & 0xFF) * 114) / 1000) & 0xFF) | + (uint16)((*src >> 16) & 0xFF00)); #endif - dest++; - src++; + dest++; + src++; + } } - } } void TxQuantize::ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height) { - int x, y; - uint8 *dest = (uint8 *)dst; - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { + int x, y; + uint8 *dest = (uint8 *)dst; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { #if 1 - /* libpng style Intensity = (6969 * R + 23434 * G + 2365 * B)/32768 */ - *dest = (int)((((*src >> 16) & 0xFF) * 6969 + - ((*src >> 8) & 0xFF) * 23434 + - ((*src ) & 0xFF) * 2365) / 32768) & 0xFF; + /* libpng style Intensity = (6969 * R + 23434 * G + 2365 * B)/32768 */ + * dest = (int)((((*src >> 16) & 0xFF) * 6969 + + ((*src >> 8) & 0xFF) * 23434 + + ((*src) & 0xFF) * 2365) / 32768) & 0xFF; #else - /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 - * this is same as the standard NTSC gray scale conversion. */ - *dest = (int)((((*src >>16) & 0xFF) * 299 + - ((*src >> 8) & 0xFF) * 587 + - ((*src ) & 0xFF) * 114) / 1000) & 0xFF; + /* 3dfx style Intensity = R * 0.299 + G * 0.587 + B * 0.114 + * this is same as the standard NTSC gray scale conversion. */ + *dest = (int)((((*src >> 16) & 0xFF) * 299 + + ((*src >> 8) & 0xFF) * 587 + + ((*src) & 0xFF) * 114) / 1000) & 0xFF; #endif - dest++; - src++; + dest++; + src++; + } } - } } void TxQuantize::P8_16BPP(uint32* src, uint32* dest, int width, int height, uint32* palette) { - /* passed in palette is RGBA5551 format */ + /* passed in palette is RGBA5551 format */ #if 1 - int i; - int size = width * height; - for (i = 0; i < size; i++) { - ((uint16*)dest)[i] = ((uint16*)palette)[(int)(((uint8*)src)[i])]; - ((uint16*)dest)[i] = ((((uint16*)dest)[i] << 15) | (((uint16*)dest)[i] >> 1)); - } + int i; + int size = width * height; + for (i = 0; i < size; i++) { + ((uint16*)dest)[i] = ((uint16*)palette)[(int)(((uint8*)src)[i])]; + ((uint16*)dest)[i] = ((((uint16*)dest)[i] << 15) | (((uint16*)dest)[i] >> 1)); + } #else /* not finished yet... */ - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; - mov edx, dword ptr [palette]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; + mov edx, dword ptr[palette]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } #endif } -boolean -TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, boolean fastQuantizer) +bool +TxQuantize::quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, bool fastQuantizer) { - typedef void (TxQuantize::*quantizerFunc)(uint32* src, uint32* dest, int width, int height); - quantizerFunc quantizer; - int bpp_shift = 0; + typedef void (TxQuantize::*quantizerFunc)(uint32* src, uint32* dest, int width, int height); + quantizerFunc quantizer; + int bpp_shift = 0; - if (destformat == GR_TEXFMT_ARGB_8888) { - switch (srcformat) { - case GR_TEXFMT_ARGB_1555: - quantizer = &TxQuantize::ARGB1555_ARGB8888; - bpp_shift = 1; - break; - case GR_TEXFMT_ARGB_4444: - quantizer = &TxQuantize::ARGB4444_ARGB8888; - bpp_shift = 1; - break; - case GR_TEXFMT_RGB_565: - quantizer = &TxQuantize::RGB565_ARGB8888; - bpp_shift = 1; - break; - case GR_TEXFMT_ALPHA_8: - quantizer = &TxQuantize::A8_ARGB8888; - bpp_shift = 2; - break; - case GR_TEXFMT_ALPHA_INTENSITY_44: - quantizer = &TxQuantize::AI44_ARGB8888; - bpp_shift = 2; - break; - case GR_TEXFMT_ALPHA_INTENSITY_88: - quantizer = &TxQuantize::AI88_ARGB8888; - bpp_shift = 1; - break; - default: - return 0; + if (destformat == GFX_TEXFMT_ARGB_8888) { + switch (srcformat) { + case GFX_TEXFMT_ARGB_1555: + quantizer = &TxQuantize::ARGB1555_ARGB8888; + bpp_shift = 1; + break; + case GFX_TEXFMT_ARGB_4444: + quantizer = &TxQuantize::ARGB4444_ARGB8888; + bpp_shift = 1; + break; + case GFX_TEXFMT_RGB_565: + quantizer = &TxQuantize::RGB565_ARGB8888; + bpp_shift = 1; + break; + case GFX_TEXFMT_ALPHA_8: + quantizer = &TxQuantize::A8_ARGB8888; + bpp_shift = 2; + break; + case GFX_TEXFMT_ALPHA_INTENSITY_44: + quantizer = &TxQuantize::AI44_ARGB8888; + bpp_shift = 2; + break; + case GFX_TEXFMT_ALPHA_INTENSITY_88: + quantizer = &TxQuantize::AI88_ARGB8888; + bpp_shift = 1; + break; + default: + return 0; + } + + unsigned int numcore = _numcore; + unsigned int blkrow = 0; + while (numcore > 1 && blkrow == 0) { + blkrow = (height >> 2) / numcore; + numcore--; + } + (*this.*quantizer)((uint32*)src, (uint32*)dest, width, height); + } + else if (srcformat == GFX_TEXFMT_ARGB_8888) { + switch (destformat) { + case GFX_TEXFMT_ARGB_1555: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB1555 : &TxQuantize::ARGB8888_ARGB1555_ErrD; + bpp_shift = 1; + break; + case GFX_TEXFMT_ARGB_4444: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB4444 : &TxQuantize::ARGB8888_ARGB4444_ErrD; + bpp_shift = 1; + break; + case GFX_TEXFMT_RGB_565: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_RGB565 : &TxQuantize::ARGB8888_RGB565_ErrD; + bpp_shift = 1; + break; + case GFX_TEXFMT_ALPHA_8: + case GFX_TEXFMT_INTENSITY_8: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_A8 : &TxQuantize::ARGB8888_I8_Slow; + bpp_shift = 2; + break; + case GFX_TEXFMT_ALPHA_INTENSITY_44: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI44 : &TxQuantize::ARGB8888_AI44_ErrD; + bpp_shift = 2; + break; + case GFX_TEXFMT_ALPHA_INTENSITY_88: + quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI88 : &TxQuantize::ARGB8888_AI88_Slow; + bpp_shift = 1; + break; + default: + return 0; + } + (*this.*quantizer)((uint32*)src, (uint32*)dest, width, height); + } + else { + return 0; } - unsigned int numcore = _numcore; - unsigned int blkrow = 0; - while (numcore > 1 && blkrow == 0) { - blkrow = (height >> 2) / numcore; - numcore--; - } - (*this.*quantizer)((uint32*)src, (uint32*)dest, width, height); - - } else if (srcformat == GR_TEXFMT_ARGB_8888) { - switch (destformat) { - case GR_TEXFMT_ARGB_1555: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB1555 : &TxQuantize::ARGB8888_ARGB1555_ErrD; - bpp_shift = 1; - break; - case GR_TEXFMT_ARGB_4444: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_ARGB4444 : &TxQuantize::ARGB8888_ARGB4444_ErrD; - bpp_shift = 1; - break; - case GR_TEXFMT_RGB_565: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_RGB565 : &TxQuantize::ARGB8888_RGB565_ErrD; - bpp_shift = 1; - break; - case GR_TEXFMT_ALPHA_8: - case GR_TEXFMT_INTENSITY_8: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_A8 : &TxQuantize::ARGB8888_I8_Slow; - bpp_shift = 2; - break; - case GR_TEXFMT_ALPHA_INTENSITY_44: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI44 : &TxQuantize::ARGB8888_AI44_ErrD; - bpp_shift = 2; - break; - case GR_TEXFMT_ALPHA_INTENSITY_88: - quantizer = fastQuantizer ? &TxQuantize::ARGB8888_AI88 : &TxQuantize::ARGB8888_AI88_Slow; - bpp_shift = 1; - break; - default: - return 0; - } - (*this.*quantizer)((uint32*)src, (uint32*)dest, width, height); - - } else { - return 0; - } - - return 1; + return 1; } -boolean +bool TxQuantize::FXT1(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat) + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat) { - /* - * NOTE: src must be in ARGB8888 format, srcformat describes - * the closest 16bbp representation of src. - * - * NOTE: I have modified the dxtn library to use ARGB format - * which originaly was ABGR format. - */ - - boolean bRet = 0; - - if (_tx_compress_fxt1 && - srcwidth >= 8 && srcheight >= 4) { - /* compress to fxt1 - * width and height must be larger than 8 and 4 respectively + /* + * NOTE: src must be in ARGB8888 format, srcformat describes + * the closest 16bbp representation of src. + * + * NOTE: I have modified the dxtn library to use ARGB format + * which originaly was ABGR format. */ - int dstRowStride = ((srcwidth + 7) & ~7) << 1; - int srcRowStride = (srcwidth << 2); - unsigned int numcore = _numcore; - unsigned int blkrow = 0; - while (numcore > 1 && blkrow == 0) { - blkrow = (srcheight >> 2) / numcore; - numcore--; + bool bRet = 0; + + if (_tx_compress_fxt1 && + srcwidth >= 8 && srcheight >= 4) { + /* compress to fxt1 + * width and height must be larger than 8 and 4 respectively + */ + int dstRowStride = ((srcwidth + 7) & ~7) << 1; + int srcRowStride = (srcwidth << 2); + + unsigned int numcore = _numcore; + unsigned int blkrow = 0; + while (numcore > 1 && blkrow == 0) { + blkrow = (srcheight >> 2) / numcore; + numcore--; + } + (*_tx_compress_fxt1)(srcwidth, /* width */ + srcheight, /* height */ + 4, /* comps: ARGB8888=4, RGB888=3 */ + src, /* source */ + srcRowStride, /* width*comps */ + dest, /* destination */ + dstRowStride); /* 16 bytes per 8x4 texel */ + +/* dxtn adjusts width and height to M8 and M4 respectively by replication */ + *destwidth = (srcwidth + 7) & ~7; + *destheight = (srcheight + 3) & ~3; + *destformat = GFX_TEXFMT_ARGB_CMP_FXT1; + + bRet = 1; } - (*_tx_compress_fxt1)(srcwidth, /* width */ - srcheight, /* height */ - 4, /* comps: ARGB8888=4, RGB888=3 */ - src, /* source */ - srcRowStride, /* width*comps */ - dest, /* destination */ - dstRowStride); /* 16 bytes per 8x4 texel */ - /* dxtn adjusts width and height to M8 and M4 respectively by replication */ - *destwidth = (srcwidth + 7) & ~7; - *destheight = (srcheight + 3) & ~3; - *destformat = GR_TEXFMT_ARGB_CMP_FXT1; - - bRet = 1; - } - - return bRet; + return bRet; } -boolean +bool TxQuantize::DXTn(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat) + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat) { - /* - * NOTE: src must be in ARGB8888 format, srcformat describes - * the closest 16bbp representation of src. - * - * NOTE: I have modified the dxtn library to use ARGB format - * which originaly was ABGR format. - */ - - boolean bRet = 0; - - if (_tx_compress_dxtn && - srcwidth >= 4 && srcheight >= 4) { - /* compress to dxtn - * width and height must be larger than 4 + /* + * NOTE: src must be in ARGB8888 format, srcformat describes + * the closest 16bbp representation of src. + * + * NOTE: I have modified the dxtn library to use ARGB format + * which originaly was ABGR format. */ - /* skip formats that DXTn won't help in size. */ - if (srcformat == GR_TEXFMT_ALPHA_8 || - srcformat == GR_TEXFMT_ALPHA_INTENSITY_44) { - ; /* shutup compiler */ - } else { - int dstRowStride = ((srcwidth + 3) & ~3) << 2; - int compression = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + bool bRet = 0; - *destformat = GR_TEXFMT_ARGB_CMP_DXT5; + if (_tx_compress_dxtn && + srcwidth >= 4 && srcheight >= 4) { + /* compress to dxtn + * width and height must be larger than 4 + */ + + /* skip formats that DXTn won't help in size. */ + if (srcformat == GFX_TEXFMT_ALPHA_8 || + srcformat == GFX_TEXFMT_ALPHA_INTENSITY_44) { + ; /* shutup compiler */ + } + else { + int dstRowStride = ((srcwidth + 3) & ~3) << 2; + int compression = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + + *destformat = GFX_TEXFMT_ARGB_CMP_DXT5; #if !GLIDE64_DXTN - /* okay... we are going to disable DXT1 with 1bit alpha - * for Glide64. some textures have all 0 alpha values. - * see "N64 Kobe Bryant in NBA Courtside" - */ - if (srcformat == GR_TEXFMT_ARGB_1555) { - dstRowStride >>= 1; - compression = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - *destformat = GR_TEXFMT_ARGB_CMP_DXT1; - } else + /* okay... we are going to disable DXT1 with 1bit alpha + * for Glide64. some textures have all 0 alpha values. + * see "N64 Kobe Bryant in NBA Courtside" + */ + if (srcformat == GFX_TEXFMT_ARGB_1555) { + dstRowStride >>= 1; + compression = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + *destformat = GFX_TEXFMT_ARGB_CMP_DXT1; + } + else #endif - if (srcformat == GR_TEXFMT_RGB_565 || - srcformat == GR_TEXFMT_INTENSITY_8) { - dstRowStride >>= 1; - compression = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; - *destformat = GR_TEXFMT_ARGB_CMP_DXT1; - } + if (srcformat == GFX_TEXFMT_RGB_565 || + srcformat == GFX_TEXFMT_INTENSITY_8) { + dstRowStride >>= 1; + compression = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; + *destformat = GFX_TEXFMT_ARGB_CMP_DXT1; + } - unsigned int numcore = _numcore; - unsigned int blkrow = 0; - while (numcore > 1 && blkrow == 0) { - blkrow = (srcheight >> 2) / numcore; - numcore--; - } - (*_tx_compress_dxtn)(4, /* comps: ARGB8888=4, RGB888=3 */ - srcwidth, /* width */ - srcheight, /* height */ - src, /* source */ - compression, /* format */ - dest, /* destination */ - dstRowStride); /* DXT1 = 8 bytes per 4x4 texel - * others = 16 bytes per 4x4 texel */ + unsigned int numcore = _numcore; + unsigned int blkrow = 0; + while (numcore > 1 && blkrow == 0) { + blkrow = (srcheight >> 2) / numcore; + numcore--; + } + (*_tx_compress_dxtn)(4, /* comps: ARGB8888=4, RGB888=3 */ + srcwidth, /* width */ + srcheight, /* height */ + src, /* source */ + compression, /* format */ + dest, /* destination */ + dstRowStride); /* DXT1 = 8 bytes per 4x4 texel + * others = 16 bytes per 4x4 texel */ - /* dxtn adjusts width and height to M4 by replication */ - *destwidth = (srcwidth + 3) & ~3; - *destheight = (srcheight + 3) & ~3; + /* dxtn adjusts width and height to M4 by replication */ + *destwidth = (srcwidth + 3) & ~3; + *destheight = (srcheight + 3) & ~3; - bRet = 1; + bRet = 1; + } } - } - return bRet; + return bRet; } -boolean +bool TxQuantize::compress(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat, - int compressionType) + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat, + int compressionType) { - boolean bRet = 0; + bool bRet = 0; - switch (compressionType) { - case FXT1_COMPRESSION: - bRet = FXT1(src, dest, - srcwidth, srcheight, srcformat, - destwidth, destheight, destformat); - break; - case S3TC_COMPRESSION: - bRet = DXTn(src, dest, - srcwidth, srcheight, srcformat, - destwidth, destheight, destformat); - break; - case NCC_COMPRESSION: - /* TODO: narrow channel compression */ - ; - } + switch (compressionType) { + case FXT1_COMPRESSION: + bRet = FXT1(src, dest, + srcwidth, srcheight, srcformat, + destwidth, destheight, destformat); + break; + case S3TC_COMPRESSION: + bRet = DXTn(src, dest, + srcwidth, srcheight, srcformat, + destwidth, destheight, destformat); + break; + case NCC_COMPRESSION: + /* TODO: narrow channel compression */ + ; + } - return bRet; + return bRet; } #if 0 /* unused */ void TxQuantize::I8_ARGB8888(uint32* src, uint32* dest, int width, int height) { - int siz = (width * height) >> 2; + int siz = (width * height) >> 2; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaaaaaa - // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa - mov edx, eax; - and eax, 0x000000ff; - mov ebx, eax; // 00000000 00000000 00000000 aaaaaaaa - shl ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 - or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa - shl ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 - or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa + // aaaaaaaa + // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa + mov edx, eax; + and eax, 0x000000ff; + mov ebx, eax; // 00000000 00000000 00000000 aaaaaaaa + shl ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 + or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa + shl ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 + or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x0000ff00; - mov ebx, eax; // 00000000 00000000 aaaaaaaa 00000000 - shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa - or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa - shl ebx, 16; // 00000000 aaaaaaaa 00000000 00000000 - or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa + mov eax, edx; + and eax, 0x0000ff00; + mov ebx, eax; // 00000000 00000000 aaaaaaaa 00000000 + shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa + or eax, ebx; // 00000000 00000000 aaaaaaaa aaaaaaaa + shl ebx, 16; // 00000000 aaaaaaaa 00000000 00000000 + or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0x00ff0000; - mov ebx, eax; // 00000000 aaaaaaaa 00000000 00000000 - shr ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 - or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa 00000000 - shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa - or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa + mov eax, edx; + and eax, 0x00ff0000; + mov ebx, eax; // 00000000 aaaaaaaa 00000000 00000000 + shr ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 + or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa 00000000 + shr ebx, 8; // 00000000 00000000 00000000 aaaaaaaa + or eax, ebx; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - mov eax, edx; - and eax, 0xff000000; - mov ebx, eax; // aaaaaaaa 00000000 00000000 00000000 - shr ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 - or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 - shr ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 - or eax, ebx; // aaaaaaaa aaaaaaaa aaaaaaaa 00000000 - shr eax, 8; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa - or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa + mov eax, edx; + and eax, 0xff000000; + mov ebx, eax; // aaaaaaaa 00000000 00000000 00000000 + shr ebx, 8; // 00000000 aaaaaaaa 00000000 00000000 + or eax, ebx; // aaaaaaaa aaaaaaaa 00000000 00000000 + shr ebx, 8; // 00000000 00000000 aaaaaaaa 00000000 + or eax, ebx; // aaaaaaaa aaaaaaaa aaaaaaaa 00000000 + shr eax, 8; // 00000000 aaaaaaaa aaaaaaaa aaaaaaaa + or eax, 0xff000000; // 11111111 aaaaaaaa aaaaaaaa aaaaaaaa - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } } void TxQuantize::ARGB8888_I8(uint32* src, uint32* dest, int width, int height) { - ARGB8888_A8(src, dest, width, height); + ARGB8888_A8(src, dest, width, height); } void TxQuantize::ARGB1555_ABGR8888(uint32* src, uint32* dest, int width, int height) { - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // arrr rrgg gggb bbbb - // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov edx, eax; // edx = arrrrrgg gggbbbbb arrrrrgg gggbbbbb - and ebx, 0x00000000; - and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 - jz transparent1; - or ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 + // arrr rrgg gggb bbbb + // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + mov edx, eax; // edx = arrrrrgg gggbbbbb arrrrrgg gggbbbbb + and ebx, 0x00000000; + and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 + jz transparent1; + or ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 - transparent1: - mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb - and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb - shl edx, 14; // edx = 00000000 00000bbb bb000000 00000000 - or ebx, edx; // ebx = aaaaaaaa 00000bbb bb000000 00000000 - shl edx, 5; // edx = 00000000 bbbbb000 00000000 00000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb bb000000 00000000 - and ebx, 0xffff0000; // ebx = aaaaaaaa bbbbbbbb 00000000 00000000 - mov edx, eax; - and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 - shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb 00000ggg gg000000 - shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg gg000000 - and ebx, 0xffffff00; // ebx = aaaaaaaa bbbbbbbb gggggggg 00000000 - mov edx, eax; - and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 - shr edx, 7; // edx = 00000000 00000000 00000000 rrrrr000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrr000 - shr edx, 5; // edx = 00000000 00000000 00000000 00000rrr - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + transparent1: + mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb + and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb + shl edx, 14; // edx = 00000000 00000bbb bb000000 00000000 + or ebx, edx; // ebx = aaaaaaaa 00000bbb bb000000 00000000 + shl edx, 5; // edx = 00000000 bbbbb000 00000000 00000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb bb000000 00000000 + and ebx, 0xffff0000; // ebx = aaaaaaaa bbbbbbbb 00000000 00000000 + mov edx, eax; + and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 + shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb 00000ggg gg000000 + shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg gg000000 + and ebx, 0xffffff00; // ebx = aaaaaaaa bbbbbbbb gggggggg 00000000 + mov edx, eax; + and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 + shr edx, 7; // edx = 00000000 00000000 00000000 rrrrr000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrr000 + shr edx, 5; // edx = 00000000 00000000 00000000 00000rrr + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov dword ptr [edi], ebx; - add edi, 4; + mov dword ptr[edi], ebx; + add edi, 4; - shr eax, 16; // eax = 00000000 00000000 arrrrrgg gggbbbbb - mov edx, eax; // edx = 00000000 00000000 arrrrrgg gggbbbbb - and ebx, 0x00000000; - and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 - jz transparent2; - or ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 + shr eax, 16; // eax = 00000000 00000000 arrrrrgg gggbbbbb + mov edx, eax; // edx = 00000000 00000000 arrrrrgg gggbbbbb + and ebx, 0x00000000; + and eax, 0x00008000; // eax = 00000000 00000000 a0000000 00000000 + jz transparent2; + or ebx, 0xff000000; // ebx = aaaaaaaa 00000000 00000000 00000000 - transparent2: - mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb - and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb - shl edx, 14; // edx = 00000000 00000bbb bb000000 00000000 - or ebx, edx; // ebx = aaaaaaaa 00000bbb bb000000 00000000 - shl edx, 5; // edx = 00000000 bbbbb000 00000000 00000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb bb000000 00000000 - and ebx, 0xffff0000; // ebx = aaaaaaaa bbbbbbbb 00000000 00000000 - mov edx, eax; - and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 - shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb 00000ggg gg000000 - shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg gg000000 - and ebx, 0xffffff00; // ebx = aaaaaaaa bbbbbbbb gggggggg 00000000 - mov edx, eax; - and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 - shr edx, 7; // edx = 00000000 00000000 00000000 rrrrr000 - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrr000 - shr edx, 5; // edx = 00000000 00000000 00000000 00000rrr - or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + transparent2: + mov eax, edx; // eax = arrrrrgg gggbbbbb arrrrrgg gggbbbbb + and edx, 0x0000001f; // edx = 00000000 00000000 00000000 000bbbbb + shl edx, 14; // edx = 00000000 00000bbb bb000000 00000000 + or ebx, edx; // ebx = aaaaaaaa 00000bbb bb000000 00000000 + shl edx, 5; // edx = 00000000 bbbbb000 00000000 00000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb bb000000 00000000 + and ebx, 0xffff0000; // ebx = aaaaaaaa bbbbbbbb 00000000 00000000 + mov edx, eax; + and edx, 0x000003e0; // edx = 00000000 00000000 000000gg ggg00000 + shl edx, 1; // edx = 00000000 00000000 00000ggg gg000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb 00000ggg gg000000 + shl edx, 5; // edx = 00000000 00000000 ggggg000 00000000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg gg000000 + and ebx, 0xffffff00; // ebx = aaaaaaaa bbbbbbbb gggggggg 00000000 + mov edx, eax; + and edx, 0x00007c00; // edx = 00000000 00000000 0rrrrr00 00000000 + shr edx, 7; // edx = 00000000 00000000 00000000 rrrrr000 + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrr000 + shr edx, 5; // edx = 00000000 00000000 00000000 00000rrr + or ebx, edx; // ebx = aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov dword ptr [edi], ebx; - add edi, 4; + mov dword ptr[edi], ebx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } } void TxQuantize::ARGB4444_ABGR8888(uint32* src, uint32* dest, int width, int height) { - int siz = (width * height) >> 1; + int siz = (width * height) >> 1; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaa rrrr gggg bbbb - // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov edx, eax; - and eax, 0x0000ffff; - mov ebx, eax; // 00000000 00000000 aaaarrrr ggggbbbb - and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 - shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 - or eax, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x0000000f; // 00000000 00000000 00000000 0000bbbb - shl ebx, 16; // 00000000 0000bbbb 00000000 00000000 - or eax, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggbbbb - mov ebx, eax; - and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 - shr ebx, 8; // 00000000 00000000 00000000 0000rrrr - and eax, 0xfffffff0; - or eax, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggrrrr - mov ebx, eax; - and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 - shl ebx, 4; // 00000000 00000000 0000gggg 00000000 - and eax, 0x0f0f000f; // 0000aaaa 0000bbbb 00000000 0000rrrr - or eax, ebx; // 0000aaaa 0000bbbb 0000gggg 0000rrrr - mov ebx, eax; - shl ebx, 4; // aaaa0000 bbbb0000 gggg0000 rrrr0000 - or eax, ebx; // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + // aaaa rrrr gggg bbbb + // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + mov edx, eax; + and eax, 0x0000ffff; + mov ebx, eax; // 00000000 00000000 aaaarrrr ggggbbbb + and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 + shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 + or eax, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x0000000f; // 00000000 00000000 00000000 0000bbbb + shl ebx, 16; // 00000000 0000bbbb 00000000 00000000 + or eax, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggbbbb + mov ebx, eax; + and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 + shr ebx, 8; // 00000000 00000000 00000000 0000rrrr + and eax, 0xfffffff0; + or eax, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggrrrr + mov ebx, eax; + and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 + shl ebx, 4; // 00000000 00000000 0000gggg 00000000 + and eax, 0x0f0f000f; // 0000aaaa 0000bbbb 00000000 0000rrrr + or eax, ebx; // 0000aaaa 0000bbbb 0000gggg 0000rrrr + mov ebx, eax; + shl ebx, 4; // aaaa0000 bbbb0000 gggg0000 rrrr0000 + or eax, ebx; // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov dword ptr [edi], eax; + mov dword ptr[edi], eax; - add edi, 4; + add edi, 4; - shr edx, 16; - mov ebx, edx; // 00000000 00000000 aaaarrrr ggggbbbb - and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 - shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 - or edx, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb - mov ebx, edx; - and ebx, 0x0000000f; // 00000000 00000000 00000000 0000bbbb - shl ebx, 16; // 00000000 0000bbbb 00000000 00000000 - or edx, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggbbbb - mov ebx, edx; - and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 - shr ebx, 8; // 00000000 00000000 00000000 0000rrrr - and edx, 0xfffffff0; - or edx, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggrrrr - mov ebx, edx; - and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 - shl ebx, 4; // 00000000 00000000 0000gggg 00000000 - and edx, 0x0f0f000f; // 0000aaaa 0000bbbb 00000000 0000rrrr - or edx, ebx; // 0000aaaa 0000bbbb 0000gggg 0000rrrr - mov ebx, edx; - shl ebx, 4; // aaaa0000 bbbb0000 gggg0000 rrrr0000 - or edx, ebx; // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + shr edx, 16; + mov ebx, edx; // 00000000 00000000 aaaarrrr ggggbbbb + and ebx, 0x0000f000; // 00000000 00000000 aaaa0000 00000000 + shl ebx, 12; // 0000aaaa 00000000 00000000 00000000 + or edx, ebx; // 0000aaaa 00000000 aaaarrrr ggggbbbb + mov ebx, edx; + and ebx, 0x0000000f; // 00000000 00000000 00000000 0000bbbb + shl ebx, 16; // 00000000 0000bbbb 00000000 00000000 + or edx, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggbbbb + mov ebx, edx; + and ebx, 0x00000f00; // 00000000 00000000 0000rrrr 00000000 + shr ebx, 8; // 00000000 00000000 00000000 0000rrrr + and edx, 0xfffffff0; + or edx, ebx; // 0000aaaa 0000bbbb aaaarrrr ggggrrrr + mov ebx, edx; + and ebx, 0x000000f0; // 00000000 00000000 00000000 gggg0000 + shl ebx, 4; // 00000000 00000000 0000gggg 00000000 + and edx, 0x0f0f000f; // 0000aaaa 0000bbbb 00000000 0000rrrr + or edx, ebx; // 0000aaaa 0000bbbb 0000gggg 0000rrrr + mov ebx, edx; + shl ebx, 4; // aaaa0000 bbbb0000 gggg0000 rrrr0000 + or edx, ebx; // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov dword ptr [edi], edx; - add edi, 4; + mov dword ptr[edi], edx; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } } void TxQuantize::ARGB8888_ABGR8888(uint32* src, uint32* dest, int width, int height) { - int siz = width * height; + int siz = width * height; - __asm { - push ebx; - push esi; - push edi; + __asm { + push ebx; + push esi; + push edi; - mov esi, dword ptr [src]; - mov edi, dword ptr [dest]; - mov ecx, dword ptr [siz]; + mov esi, dword ptr[src]; + mov edi, dword ptr[dest]; + mov ecx, dword ptr[siz]; - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; + tc1_loop: + mov eax, dword ptr[esi]; + add esi, 4; - // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr - mov edx, eax; - bswap edx; - shr edx, 8; - and eax, 0xff000000; + // aaaaaaaa bbbbbbbb gggggggg rrrrrrrr + mov edx, eax; + bswap edx; + shr edx, 8; + and eax, 0xff000000; - or eax, edx; + or eax, edx; - mov dword ptr [edi], eax; - add edi, 4; + mov dword ptr[edi], eax; + add edi, 4; - dec ecx; - jnz tc1_loop; + dec ecx; + jnz tc1_loop; - pop edi; - pop esi; - pop ebx; - } + pop edi; + pop esi; + pop ebx; + } } -#endif +#endif \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxQuantize.h b/Source/Project64-video/TextureEnhancer/TxQuantize.h index d3c6ae6dc..4aa492de4 100644 --- a/Source/Project64-video/TextureEnhancer/TxQuantize.h +++ b/Source/Project64-video/TextureEnhancer/TxQuantize.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXQUANTIZE_H__ #define __TXQUANTIZE_H__ @@ -34,65 +25,64 @@ class TxQuantize { private: - TxUtil *_txUtil; - int _numcore; + TxUtil *_txUtil; + int _numcore; - fxtCompressTexFuncExt _tx_compress_fxt1; - dxtCompressTexFuncExt _tx_compress_dxtn; + fxtCompressTexFuncExt _tx_compress_fxt1; + dxtCompressTexFuncExt _tx_compress_dxtn; - /* fast optimized... well, sort of. */ - void ARGB1555_ARGB8888(uint32* src, uint32* dst, int width, int height); - void ARGB4444_ARGB8888(uint32* src, uint32* dst, int width, int height); - void RGB565_ARGB8888(uint32* src, uint32* dst, int width, int height); - void A8_ARGB8888(uint32* src, uint32* dst, int width, int height); - void AI44_ARGB8888(uint32* src, uint32* dst, int width, int height); - void AI88_ARGB8888(uint32* src, uint32* dst, int width, int height); + /* fast optimized... well, sort of. */ + void ARGB1555_ARGB8888(uint32* src, uint32* dst, int width, int height); + void ARGB4444_ARGB8888(uint32* src, uint32* dst, int width, int height); + void RGB565_ARGB8888(uint32* src, uint32* dst, int width, int height); + void A8_ARGB8888(uint32* src, uint32* dst, int width, int height); + void AI44_ARGB8888(uint32* src, uint32* dst, int width, int height); + void AI88_ARGB8888(uint32* src, uint32* dst, int width, int height); - void ARGB8888_ARGB1555(uint32* src, uint32* dst, int width, int height); - void ARGB8888_ARGB4444(uint32* src, uint32* dst, int width, int height); - void ARGB8888_RGB565(uint32* src, uint32* dst, int width, int height); - void ARGB8888_A8(uint32* src, uint32* dst, int width, int height); - void ARGB8888_AI44(uint32* src, uint32* dst, int width, int height); - void ARGB8888_AI88(uint32* src, uint32* dst, int width, int height); + void ARGB8888_ARGB1555(uint32* src, uint32* dst, int width, int height); + void ARGB8888_ARGB4444(uint32* src, uint32* dst, int width, int height); + void ARGB8888_RGB565(uint32* src, uint32* dst, int width, int height); + void ARGB8888_A8(uint32* src, uint32* dst, int width, int height); + void ARGB8888_AI44(uint32* src, uint32* dst, int width, int height); + void ARGB8888_AI88(uint32* src, uint32* dst, int width, int height); - /* quality */ - void ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height); - void ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height); - void ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height); - void ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height); - void ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height); - void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height); + /* quality */ + void ARGB8888_RGB565_ErrD(uint32* src, uint32* dst, int width, int height); + void ARGB8888_ARGB1555_ErrD(uint32* src, uint32* dst, int width, int height); + void ARGB8888_ARGB4444_ErrD(uint32* src, uint32* dst, int width, int height); + void ARGB8888_AI44_ErrD(uint32* src, uint32* dst, int width, int height); + void ARGB8888_AI88_Slow(uint32* src, uint32* dst, int width, int height); + void ARGB8888_I8_Slow(uint32* src, uint32* dst, int width, int height); - /* compressors */ - boolean FXT1(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat); - boolean DXTn(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat); + /* compressors */ + bool FXT1(uint8 *src, uint8 *dest, + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat); + bool DXTn(uint8 *src, uint8 *dest, + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat); public: - TxQuantize(); - ~TxQuantize(); + TxQuantize(); + ~TxQuantize(); - /* others */ - void P8_16BPP(uint32* src, uint32* dst, int width, int height, uint32* palette); + /* others */ + void P8_16BPP(uint32* src, uint32* dst, int width, int height, uint32* palette); - boolean quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, boolean fastQuantizer = 1); - - boolean compress(uint8 *src, uint8 *dest, - int srcwidth, int srcheight, uint16 srcformat, - int *destwidth, int *destheight, uint16 *destformat, - int compressionType); + bool quantize(uint8* src, uint8* dest, int width, int height, uint16 srcformat, uint16 destformat, bool fastQuantizer = 1); + bool compress(uint8 *src, uint8 *dest, + int srcwidth, int srcheight, uint16 srcformat, + int *destwidth, int *destheight, uint16 *destformat, + int compressionType); #if 0 /* unused */ - void ARGB8888_I8(uint32* src, uint32* dst, int width, int height); - void I8_ARGB8888(uint32* src, uint32* dst, int width, int height); - - void ARGB1555_ABGR8888(uint32* src, uint32* dst, int width, int height); - void ARGB4444_ABGR8888(uint32* src, uint32* dst, int width, int height); - void ARGB8888_ABGR8888(uint32* src, uint32* dst, int width, int height); + void ARGB8888_I8(uint32* src, uint32* dst, int width, int height); + void I8_ARGB8888(uint32* src, uint32* dst, int width, int height); + + void ARGB1555_ABGR8888(uint32* src, uint32* dst, int width, int height); + void ARGB4444_ABGR8888(uint32* src, uint32* dst, int width, int height); + void ARGB8888_ABGR8888(uint32* src, uint32* dst, int width, int height); #endif }; diff --git a/Source/Project64-video/TextureEnhancer/TxReSample.cpp b/Source/Project64-video/TextureEnhancer/TxReSample.cpp index 66c4154d1..edcc906f0 100644 --- a/Source/Project64-video/TextureEnhancer/TxReSample.cpp +++ b/Source/Project64-video/TextureEnhancer/TxReSample.cpp @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "TxReSample.h" #include "TxDbg.h" @@ -36,109 +27,110 @@ int TxReSample::nextPow2(int num) { - num = num - 1; - num = num | (num >> 1); - num = num | (num >> 2); - num = num | (num >> 4); - num = num | (num >> 8); - num = num | (num >> 16); - /*num = num | (num >> 32);*//* for 64bit architecture */ - num = num + 1; + num = num - 1; + num = num | (num >> 1); + num = num | (num >> 2); + num = num | (num >> 4); + num = num | (num >> 8); + num = num | (num >> 16); + /*num = num | (num >> 32);*//* for 64bit architecture */ + num = num + 1; - return num; + return num; } -boolean -TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx = 0) +bool +TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx = 0) { - /* NOTE: bpp must be one of the follwing: 8, 16, 24, 32 bits per pixel */ + /* NOTE: bpp must be one of the follwing: 8, 16, 24, 32 bits per pixel */ + + if (!*image || !*width || !*height || !bpp) + return 0; + + int row_bytes = ((*width * bpp) >> 3); + int o_row_bytes = row_bytes; + int o_width = *width; + int n_width = *width; + int o_height = *height; + int n_height = *height; + + /* HACKALERT: I have explicitly subtracted (n) from width/height to + * adjust textures that have (n) pixel larger width/height than + * power of 2 size. This is a dirty hack for textures that have + * munged aspect ratio by (n) pixel to the original. + */ + if (n_width > 64) n_width -= 4; + else if (n_width > 16) n_width -= 2; + else if (n_width > 4) n_width -= 1; + + if (n_height > 64) n_height -= 4; + else if (n_height > 16) n_height -= 2; + else if (n_height > 4) n_height -= 1; + + n_width = nextPow2(n_width); + n_height = nextPow2(n_height); + row_bytes = (n_width * bpp) >> 3; + + /* 3dfx Glide3 format, W:H aspect ratio range (8:1 - 1:8) */ + if (use_3dfx) { + if (n_width > n_height) { + if (n_width > (n_height << 3)) + n_height = n_width >> 3; + } + else { + if (n_height > (n_width << 3)) { + n_width = n_height >> 3; + row_bytes = (n_width * bpp) >> 3; + } + } + DBG_INFO(80, "using 3dfx W:H aspect ratio range (8:1 - 1:8).\n"); + } + + /* do we really need to do this ? */ + if (o_width == n_width && o_height == n_height) + return 1; /* nope */ + + DBG_INFO(80, "expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height); + + if (o_width > n_width) + o_width = n_width; + + if (o_height > n_height) + o_height = n_height; + + /* allocate memory to read in image */ + uint8 *pow2image = (uint8*)malloc(row_bytes * n_height); + + /* read in image */ + if (pow2image) { + int i, j; + uint8 *tmpimage = *image, *tmppow2image = pow2image; + + for (i = 0; i < o_height; i++) { + /* copy row */ + memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3)); + + /* expand to pow2 size by replication */ + for (j = ((o_width * bpp) >> 3); j < row_bytes; j++) + tmppow2image[j] = tmppow2image[j - (bpp >> 3)]; + + tmppow2image += row_bytes; + tmpimage += o_row_bytes; + } + /* expand to pow2 size by replication */ + for (i = o_height; i < n_height; i++) + memcpy(&pow2image[row_bytes * i], &pow2image[row_bytes * (i - 1)], row_bytes); + + free(*image); + + *image = pow2image; + *height = n_height; + *width = n_width; + + return 1; + } - if (!*image || !*width || !*height || !bpp) return 0; - - int row_bytes = ((*width * bpp) >> 3); - int o_row_bytes = row_bytes; - int o_width = *width; - int n_width = *width; - int o_height = *height; - int n_height = *height; - - /* HACKALERT: I have explicitly subtracted (n) from width/height to - * adjust textures that have (n) pixel larger width/height than - * power of 2 size. This is a dirty hack for textures that have - * munged aspect ratio by (n) pixel to the original. - */ - if (n_width > 64) n_width -= 4; - else if (n_width > 16) n_width -= 2; - else if (n_width > 4) n_width -= 1; - - if (n_height > 64) n_height -= 4; - else if (n_height > 16) n_height -= 2; - else if (n_height > 4) n_height -= 1; - - n_width = nextPow2(n_width); - n_height = nextPow2(n_height); - row_bytes = (n_width * bpp) >> 3; - - /* 3dfx Glide3 format, W:H aspect ratio range (8:1 - 1:8) */ - if (use_3dfx) { - if (n_width > n_height) { - if (n_width > (n_height << 3)) - n_height = n_width >> 3; - } else { - if (n_height > (n_width << 3)) { - n_width = n_height >> 3; - row_bytes = (n_width * bpp) >> 3; - } - } - DBG_INFO(80, "using 3dfx W:H aspect ratio range (8:1 - 1:8).\n"); - } - - /* do we really need to do this ? */ - if (o_width == n_width && o_height == n_height) - return 1; /* nope */ - - DBG_INFO(80, "expand image to next power of 2 dimensions. %d x %d -> %d x %d\n", o_width, o_height, n_width, n_height); - - if (o_width > n_width) - o_width = n_width; - - if (o_height > n_height) - o_height = n_height; - - /* allocate memory to read in image */ - uint8 *pow2image = (uint8*)malloc(row_bytes * n_height); - - /* read in image */ - if (pow2image) { - int i, j; - uint8 *tmpimage = *image, *tmppow2image = pow2image; - - for (i = 0; i < o_height; i++) { - /* copy row */ - memcpy(tmppow2image, tmpimage, ((o_width * bpp) >> 3)); - - /* expand to pow2 size by replication */ - for(j = ((o_width * bpp) >> 3); j < row_bytes; j++) - tmppow2image[j] = tmppow2image[j - (bpp >> 3)]; - - tmppow2image += row_bytes; - tmpimage += o_row_bytes; - } - /* expand to pow2 size by replication */ - for (i = o_height; i < n_height; i++) - memcpy(&pow2image[row_bytes * i], &pow2image[row_bytes * (i - 1)], row_bytes); - - free(*image); - - *image = pow2image; - *height = n_height; - *width = n_width; - - return 1; - } - - return 0; } /* Ken Turkowski @@ -148,61 +140,62 @@ TxReSample::nextPow2(uint8** image, int* width, int* height, int bpp, boolean us double TxReSample::tent(double x) { - if (x < 0.0) x = -x; - if (x < 1.0) return (1.0 - x); - return 0.0; + if (x < 0.0) x = -x; + if (x < 1.0) return (1.0 - x); + return 0.0; } double TxReSample::gaussian(double x) { - if (x < 0) x = -x; - if (x < 2.0) return pow(2.0, -2.0 * x * x); - return 0.0; + if (x < 0) x = -x; + if (x < 2.0) return pow(2.0, -2.0 * x * x); + return 0.0; } -double +double TxReSample::sinc(double x) { - if (x == 0) return 1.0; - x *= M_PI; - return (sin(x) / x); + if (x == 0) return 1.0; + x *= M_PI; + return (sin(x) / x); } -double +double TxReSample::lanczos3(double x) { - if (x < 0) x = -x; - if (x < 3.0) return (sinc(x) * sinc(x/3.0)); - return 0.0; + if (x < 0) x = -x; + if (x < 3.0) return (sinc(x) * sinc(x / 3.0)); + return 0.0; } /* Don P. Mitchell and Arun N. Netravali * Reconstruction Filters in Computer Graphics * SIGGRAPH '88 - * Proceedings of the 15th annual conference on Computer + * Proceedings of the 15th annual conference on Computer * graphics and interactive techniques, pp221-228, 1988 */ double TxReSample::mitchell(double x) { - if (x < 0) x = -x; - if (x < 2.0) { - const double B = 1.0 / 3.0; - const double C = 1.0 / 3.0; - if (x < 1.0) { - x = (((12.0 - 9.0 * B - 6.0 * C) * (x * x * x)) - + ((-18.0 + 12.0 * B + 6.0 * C) * (x * x)) - + (6.0 - 2.0 * B)); - } else { - x = (((-1.0 * B - 6.0 * C) * (x * x * x)) - + ((6.0 * B + 30.0 * C) * (x * x)) - + ((-12.0 * B - 48.0 * C) * x) - + (8.0 * B + 24.0 * C)); + if (x < 0) x = -x; + if (x < 2.0) { + const double B = 1.0 / 3.0; + const double C = 1.0 / 3.0; + if (x < 1.0) { + x = (((12.0 - 9.0 * B - 6.0 * C) * (x * x * x)) + + ((-18.0 + 12.0 * B + 6.0 * C) * (x * x)) + + (6.0 - 2.0 * B)); + } + else { + x = (((-1.0 * B - 6.0 * C) * (x * x * x)) + + ((6.0 * B + 30.0 * C) * (x * x)) + + ((-12.0 * B - 48.0 * C) * x) + + (8.0 * B + 24.0 * C)); + } + return (x / 6.0); } - return (x / 6.0); - } - return 0.0; + return 0.0; } /* J. F. Kaiser and W. A. Reed @@ -212,205 +205,205 @@ TxReSample::mitchell(double x) double TxReSample::besselI0(double x) { - /* zero-order modified bessel function of the first kind */ - const double eps_coeff = 1E-16; /* small enough */ - double xh, sum, pow, ds; - xh = 0.5 * x; - sum = 1.0; - pow = 1.0; - ds = 1.0; - int k = 0; - while (ds > sum * eps_coeff) { - k++; - pow *= (xh / k); - ds = pow * pow; - sum = sum + ds; - } - return sum; + /* zero-order modified bessel function of the first kind */ + const double eps_coeff = 1E-16; /* small enough */ + double xh, sum, pow, ds; + xh = 0.5 * x; + sum = 1.0; + pow = 1.0; + ds = 1.0; + int k = 0; + while (ds > sum * eps_coeff) { + k++; + pow *= (xh / k); + ds = pow * pow; + sum = sum + ds; + } + return sum; } double TxReSample::kaiser(double x) { - const double alpha = 4.0; - const double half_window = 5.0; - const double ratio = x / half_window; - return sinc(x) * besselI0(alpha * sqrt(1 - ratio * ratio)) / besselI0(alpha); + const double alpha = 4.0; + const double half_window = 5.0; + const double ratio = x / half_window; + return sinc(x) * besselI0(alpha * sqrt(1 - ratio * ratio)) / besselI0(alpha); } -boolean +bool TxReSample::minify(uint8 **src, int *width, int *height, int ratio) { - /* NOTE: src must be ARGB8888, ratio is the inverse representation */ + /* NOTE: src must be ARGB8888, ratio is the inverse representation */ #if 0 - if (!*src || ratio < 2) return 0; + if (!*src || ratio < 2) return 0; - /* Box filtering. - * It would be nice to do Kaiser filtering. - * N64 uses narrow strip textures which makes it hard to filter effectively. - */ + /* Box filtering. + * It would be nice to do Kaiser filtering. + * N64 uses narrow strip textures which makes it hard to filter effectively. + */ - int x, y, x2, y2, offset, numtexel; - uint32 A, R, G, B, texel; + int x, y, x2, y2, offset, numtexel; + uint32 A, R, G, B, texel; - int tmpwidth = *width / ratio; - int tmpheight = *height / ratio; + int tmpwidth = *width / ratio; + int tmpheight = *height / ratio; - uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); + uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); - if (tmptex) { - numtexel = ratio * ratio; - for (y = 0; y < tmpheight; y++) { - offset = ratio * y * *width; - for (x = 0; x < tmpwidth; x++) { - A = R = G = B = 0; - for (y2 = 0; y2 < ratio; y2++) { - for (x2 = 0; x2 < ratio; x2++) { - texel = ((uint32*)*src)[offset + *width * y2 + x2]; - A += (texel >> 24); - R += ((texel >> 16) & 0x000000ff); - G += ((texel >> 8) & 0x000000ff); - B += (texel & 0x000000ff); - } + if (tmptex) { + numtexel = ratio * ratio; + for (y = 0; y < tmpheight; y++) { + offset = ratio * y * *width; + for (x = 0; x < tmpwidth; x++) { + A = R = G = B = 0; + for (y2 = 0; y2 < ratio; y2++) { + for (x2 = 0; x2 < ratio; x2++) { + texel = ((uint32*)*src)[offset + *width * y2 + x2]; + A += (texel >> 24); + R += ((texel >> 16) & 0x000000ff); + G += ((texel >> 8) & 0x000000ff); + B += (texel & 0x000000ff); + } + } + A = (A + ratio) / numtexel; + R = (R + ratio) / numtexel; + G = (G + ratio) / numtexel; + B = (B + ratio) / numtexel; + ((uint32*)tmptex)[y * tmpwidth + x] = ((A << 24) | (R << 16) | (G << 8) | B); + offset += ratio; + } } - A = (A + ratio) / numtexel; - R = (R + ratio) / numtexel; - G = (G + ratio) / numtexel; - B = (B + ratio) / numtexel; - ((uint32*)tmptex)[y * tmpwidth + x] = ((A << 24) | (R << 16) | (G << 8) | B); - offset += ratio; - } + free(*src); + *src = tmptex; + *width = tmpwidth; + *height = tmpheight; + + DBG_INFO(80, L"minification ratio:%d -> %d x %d\n", ratio, *width, *height); + + return 1; } - free(*src); - *src = tmptex; - *width = tmpwidth; - *height = tmpheight; - DBG_INFO(80, L"minification ratio:%d -> %d x %d\n", ratio, *width, *height); + DBG_INFO(80, L"Error: failed minification!\n"); - return 1; - } - - DBG_INFO(80, L"Error: failed minification!\n"); - - return 0; + return 0; #else - if (!*src || ratio < 2) return 0; + if (!*src || ratio < 2) return 0; - /* Image Resampling */ - - /* half width of filter window. - * NOTE: must be 1.0 or larger. - * - * kaiser-bessel 5, lanczos3 3, mitchell 2, gaussian 1.5, tent 1 - */ - double half_window = 5.0; + /* Image Resampling */ - int x, y, x2, y2, z; - double A, R, G, B; - uint32 texel; + /* half width of filter window. + * NOTE: must be 1.0 or larger. + * + * kaiser-bessel 5, lanczos3 3, mitchell 2, gaussian 1.5, tent 1 + */ + double half_window = 5.0; - int tmpwidth = *width / ratio; - int tmpheight = *height / ratio; + int x, y, x2, y2, z; + double A, R, G, B; + uint32 texel; - /* resampled destination */ - uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); - if (!tmptex) return 0; + int tmpwidth = *width / ratio; + int tmpheight = *height / ratio; - /* work buffer. single row */ - uint8 *workbuf = (uint8*)malloc(*width << 2); - if (!workbuf) { - free(tmptex); - return 0; - } + /* resampled destination */ + uint8 *tmptex = (uint8*)malloc((tmpwidth * tmpheight) << 2); + if (!tmptex) return 0; - /* prepare filter lookup table. only half width required for symetric filters. */ - double *weight = (double*)malloc((int)((half_window * ratio) * sizeof(double))); - if (!weight) { - free(tmptex); + /* work buffer. single row */ + uint8 *workbuf = (uint8*)malloc(*width << 2); + if (!workbuf) { + free(tmptex); + return 0; + } + + /* prepare filter lookup table. only half width required for symetric filters. */ + double *weight = (double*)malloc((int)((half_window * ratio) * sizeof(double))); + if (!weight) { + free(tmptex); + free(workbuf); + return 0; + } + for (x = 0; x < half_window * ratio; x++) { + //weight[x] = tent((double)x / ratio) / ratio; + //weight[x] = gaussian((double)x / ratio) / ratio; + //weight[x] = lanczos3((double)x / ratio) / ratio; + //weight[x] = mitchell((double)x / ratio) / ratio; + weight[x] = kaiser((double)x / ratio) / ratio; + } + + /* linear convolution */ + for (y = 0; y < tmpheight; y++) { + for (x = 0; x < *width; x++) { + texel = ((uint32*)*src)[y * ratio * *width + x]; + A = (double)(texel >> 24) * weight[0]; + R = (double)((texel >> 16) & 0xff) * weight[0]; + G = (double)((texel >> 8) & 0xff) * weight[0]; + B = (double)((texel) & 0xff) * weight[0]; + for (y2 = 1; y2 < half_window * ratio; y2++) { + z = y * ratio + y2; + if (z >= *height) z = *height - 1; + texel = ((uint32*)*src)[z * *width + x]; + A += (double)(texel >> 24) * weight[y2]; + R += (double)((texel >> 16) & 0xff) * weight[y2]; + G += (double)((texel >> 8) & 0xff) * weight[y2]; + B += (double)((texel) & 0xff) * weight[y2]; + z = y * ratio - y2; + if (z < 0) z = 0; + texel = ((uint32*)*src)[z * *width + x]; + A += (double)(texel >> 24) * weight[y2]; + R += (double)((texel >> 16) & 0xff) * weight[y2]; + G += (double)((texel >> 8) & 0xff) * weight[y2]; + B += (double)((texel) & 0xff) * weight[y2]; + } + if (A < 0) A = 0; else if (A > 255) A = 255; + if (R < 0) R = 0; else if (R > 255) R = 255; + if (G < 0) G = 0; else if (G > 255) G = 255; + if (B < 0) B = 0; else if (B > 255) B = 255; + ((uint32*)workbuf)[x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B); + } + for (x = 0; x < tmpwidth; x++) { + texel = ((uint32*)workbuf)[x * ratio]; + A = (double)(texel >> 24) * weight[0]; + R = (double)((texel >> 16) & 0xff) * weight[0]; + G = (double)((texel >> 8) & 0xff) * weight[0]; + B = (double)((texel) & 0xff) * weight[0]; + for (x2 = 1; x2 < half_window * ratio; x2++) { + z = x * ratio + x2; + if (z >= *width) z = *width - 1; + texel = ((uint32*)workbuf)[z]; + A += (double)(texel >> 24) * weight[x2]; + R += (double)((texel >> 16) & 0xff) * weight[x2]; + G += (double)((texel >> 8) & 0xff) * weight[x2]; + B += (double)((texel) & 0xff) * weight[x2]; + z = x * ratio - x2; + if (z < 0) z = 0; + texel = ((uint32*)workbuf)[z]; + A += (double)(texel >> 24) * weight[x2]; + R += (double)((texel >> 16) & 0xff) * weight[x2]; + G += (double)((texel >> 8) & 0xff) * weight[x2]; + B += (double)((texel) & 0xff) * weight[x2]; + } + if (A < 0) A = 0; else if (A > 255) A = 255; + if (R < 0) R = 0; else if (R > 255) R = 255; + if (G < 0) G = 0; else if (G > 255) G = 255; + if (B < 0) B = 0; else if (B > 255) B = 255; + ((uint32*)tmptex)[y * tmpwidth + x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B); + } + } + + free(*src); + *src = tmptex; + free(weight); free(workbuf); - return 0; - } - for (x = 0; x < half_window * ratio; x++) { - //weight[x] = tent((double)x / ratio) / ratio; - //weight[x] = gaussian((double)x / ratio) / ratio; - //weight[x] = lanczos3((double)x / ratio) / ratio; - //weight[x] = mitchell((double)x / ratio) / ratio; - weight[x] = kaiser((double)x / ratio) / ratio; - } + *width = tmpwidth; + *height = tmpheight; - /* linear convolution */ - for (y = 0; y < tmpheight; y++) { - for (x = 0; x < *width; x++) { - texel = ((uint32*)*src)[y * ratio * *width + x]; - A = (double)(texel >> 24) * weight[0]; - R = (double)((texel >> 16) & 0xff) * weight[0]; - G = (double)((texel >> 8) & 0xff) * weight[0]; - B = (double)((texel ) & 0xff) * weight[0]; - for (y2 = 1; y2 < half_window * ratio; y2++) { - z = y * ratio + y2; - if (z >= *height) z = *height - 1; - texel = ((uint32*)*src)[z * *width + x]; - A += (double)(texel >> 24) * weight[y2]; - R += (double)((texel >> 16) & 0xff) * weight[y2]; - G += (double)((texel >> 8) & 0xff) * weight[y2]; - B += (double)((texel ) & 0xff) * weight[y2]; - z = y * ratio - y2; - if (z < 0) z = 0; - texel = ((uint32*)*src)[z * *width + x]; - A += (double)(texel >> 24) * weight[y2]; - R += (double)((texel >> 16) & 0xff) * weight[y2]; - G += (double)((texel >> 8) & 0xff) * weight[y2]; - B += (double)((texel ) & 0xff) * weight[y2]; - } - if (A < 0) A = 0; else if (A > 255) A = 255; - if (R < 0) R = 0; else if (R > 255) R = 255; - if (G < 0) G = 0; else if (G > 255) G = 255; - if (B < 0) B = 0; else if (B > 255) B = 255; - ((uint32*)workbuf)[x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B); - } - for (x = 0; x < tmpwidth; x++) { - texel = ((uint32*)workbuf)[x * ratio]; - A = (double)(texel >> 24) * weight[0]; - R = (double)((texel >> 16) & 0xff) * weight[0]; - G = (double)((texel >> 8) & 0xff) * weight[0]; - B = (double)((texel ) & 0xff) * weight[0]; - for (x2 = 1; x2 < half_window * ratio; x2++) { - z = x * ratio + x2; - if (z >= *width) z = *width - 1; - texel = ((uint32*)workbuf)[z]; - A += (double)(texel >> 24) * weight[x2]; - R += (double)((texel >> 16) & 0xff) * weight[x2]; - G += (double)((texel >> 8) & 0xff) * weight[x2]; - B += (double)((texel ) & 0xff) * weight[x2]; - z = x * ratio - x2; - if (z < 0) z = 0; - texel = ((uint32*)workbuf)[z]; - A += (double)(texel >> 24) * weight[x2]; - R += (double)((texel >> 16) & 0xff) * weight[x2]; - G += (double)((texel >> 8) & 0xff) * weight[x2]; - B += (double)((texel ) & 0xff) * weight[x2]; - } - if (A < 0) A = 0; else if (A > 255) A = 255; - if (R < 0) R = 0; else if (R > 255) R = 255; - if (G < 0) G = 0; else if (G > 255) G = 255; - if (B < 0) B = 0; else if (B > 255) B = 255; - ((uint32*)tmptex)[y * tmpwidth + x] = (((uint32)A << 24) | ((uint32)R << 16) | ((uint32)G << 8) | (uint32)B); - } - } + DBG_INFO(80, "minification ratio:%d -> %d x %d\n", ratio, *width, *height); - free(*src); - *src = tmptex; - free(weight); - free(workbuf); - *width = tmpwidth; - *height = tmpheight; - - DBG_INFO(80, "minification ratio:%d -> %d x %d\n", ratio, *width, *height); - - return 1; + return 1; #endif -} +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxReSample.h b/Source/Project64-video/TextureEnhancer/TxReSample.h index 805647d29..c378bd1d0 100644 --- a/Source/Project64-video/TextureEnhancer/TxReSample.h +++ b/Source/Project64-video/TextureEnhancer/TxReSample.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXRESAMPLE_H__ #define __TXRESAMPLE_H__ @@ -29,17 +20,17 @@ class TxReSample { private: - double tent(double x); - double gaussian(double x); - double sinc(double x); - double lanczos3(double x); - double mitchell(double x); - double besselI0(double x); - double kaiser(double x); + double tent(double x); + double gaussian(double x); + double sinc(double x); + double lanczos3(double x); + double mitchell(double x); + double besselI0(double x); + double kaiser(double x); public: - boolean minify(uint8 **src, int *width, int *height, int ratio); - boolean nextPow2(uint8** image, int* width, int* height, int bpp, boolean use_3dfx); - int nextPow2(int num); + bool minify(uint8 **src, int *width, int *height, int ratio); + bool nextPow2(uint8** image, int* width, int* height, int bpp, bool use_3dfx); + int nextPow2(int num); }; #endif /* __TXRESAMPLE_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxTexCache.cpp b/Source/Project64-video/TextureEnhancer/TxTexCache.cpp index e19367102..7696363e3 100644 --- a/Source/Project64-video/TextureEnhancer/TxTexCache.cpp +++ b/Source/Project64-video/TextureEnhancer/TxTexCache.cpp @@ -1,26 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifdef WIN32 #pragma warning(disable: 4786) #endif @@ -53,7 +43,7 @@ TxTexCache::~TxTexCache() } TxTexCache::TxTexCache(int options, int cachesize, const char *path, const char *ident, dispInfoFuncExt callback) : -TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback) + TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback) { /* assert local options */ if (_path.empty() || _ident.empty() || !_cacheSize) @@ -75,9 +65,9 @@ TxCache((options & ~GZ_HIRESTEXCACHE), cachesize, path, ident, callback) #endif } -boolean TxTexCache::add(uint64 checksum, GHQTexInfo *info) +bool TxTexCache::add(uint64_t checksum, GHQTexInfo *info) { if (_cacheSize <= 0) return 0; return TxCache::add(checksum, info); -} +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxTexCache.h b/Source/Project64-video/TextureEnhancer/TxTexCache.h index e25f424bc..750be3254 100644 --- a/Source/Project64-video/TextureEnhancer/TxTexCache.h +++ b/Source/Project64-video/TextureEnhancer/TxTexCache.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXTEXCACHE_H__ #define __TXTEXCACHE_H__ @@ -29,11 +20,11 @@ class TxTexCache : public TxCache { public: - ~TxTexCache(); - TxTexCache(int options, int cachesize, const char *path, const char *ident, - dispInfoFuncExt callback); - boolean add(uint64 checksum, /* checksum hi:palette low:texture */ - GHQTexInfo *info); + ~TxTexCache(); + TxTexCache(int options, int cachesize, const char *path, const char *ident, + dispInfoFuncExt callback); + bool add(uint64_t checksum, /* checksum hi:palette low:texture */ + GHQTexInfo *info); }; #endif /* __TXTEXCACHE_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/TxUtil.cpp b/Source/Project64-video/TextureEnhancer/TxUtil.cpp index 1edf4eef8..ea40d8c94 100644 --- a/Source/Project64-video/TextureEnhancer/TxUtil.cpp +++ b/Source/Project64-video/TextureEnhancer/TxUtil.cpp @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include "TxUtil.h" #include "TxDbg.h" @@ -27,203 +18,139 @@ #include #include #include +#include +#include /* * External libraries ******************************************************************************/ TxLoadLib::TxLoadLib() { -#ifdef DXTN_DLL - if (!_dxtnlib) - _dxtnlib = LoadLibrary("dxtn"); - - if (_dxtnlib) { - if (!_tx_compress_dxtn) - _tx_compress_dxtn = (dxtCompressTexFuncExt)DLSYM(_dxtnlib, "tx_compress_dxtn"); - - if (!_tx_compress_fxt1) - _tx_compress_fxt1 = (fxtCompressTexFuncExt)DLSYM(_dxtnlib, "fxt1_encode"); - } -#else - _tx_compress_dxtn = tx_compress_dxtn; - _tx_compress_fxt1 = fxt1_encode; - -#endif + _tx_compress_dxtn = tx_compress_dxtn; + _tx_compress_fxt1 = fxt1_encode; } TxLoadLib::~TxLoadLib() { -#ifdef DXTN_DLL - /* free dynamic library */ - if (_dxtnlib) - FreeLibrary(_dxtnlib); -#endif - } -fxtCompressTexFuncExt -TxLoadLib::getfxtCompressTexFuncExt() +fxtCompressTexFuncExt TxLoadLib::getfxtCompressTexFuncExt() { - return _tx_compress_fxt1; + return _tx_compress_fxt1; } -dxtCompressTexFuncExt -TxLoadLib::getdxtCompressTexFuncExt() +dxtCompressTexFuncExt TxLoadLib::getdxtCompressTexFuncExt() { - return _tx_compress_dxtn; + return _tx_compress_dxtn; } - /* * Utilities ******************************************************************************/ -uint32 -TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format) +uint32 TxUtil::checksumTx(uint8 *src, int width, int height, uint16 format) { - int dataSize = sizeofTx(width, height, format); + int dataSize = sizeofTx(width, height, format); - /* for now we use adler32 if something else is better - * we can simply swtich later - */ - /* return (dataSize ? Adler32(src, dataSize, 1) : 0); */ + /* for now we use adler32 if something else is better + * we can simply swtich later + */ + /* return (dataSize ? Adler32(src, dataSize, 1) : 0); */ - /* zlib crc32 */ - return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0); + /* zlib crc32 */ + return (dataSize ? crc32(crc32(0L, Z_NULL, 0), src, dataSize) : 0); } -int -TxUtil::sizeofTx(int width, int height, uint16 format) +int TxUtil::sizeofTx(int width, int height, uint16 format) { - int dataSize = 0; + int dataSize = 0; - /* a lookup table for the shifts would be better */ - switch (format) { - case GR_TEXFMT_ARGB_CMP_FXT1: - dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1; - break; - case GR_TEXFMT_ARGB_CMP_DXT1: - dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1; - break; - case GR_TEXFMT_ARGB_CMP_DXT3: - case GR_TEXFMT_ARGB_CMP_DXT5: - dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3); - break; - case GR_TEXFMT_ALPHA_INTENSITY_44: - case GR_TEXFMT_ALPHA_8: - case GR_TEXFMT_INTENSITY_8: - case GR_TEXFMT_P_8: - dataSize = width * height; - break; - case GR_TEXFMT_ARGB_4444: - case GR_TEXFMT_ARGB_1555: - case GR_TEXFMT_RGB_565: - case GR_TEXFMT_ALPHA_INTENSITY_88: - dataSize = (width * height) << 1; - break; - case GR_TEXFMT_ARGB_8888: - dataSize = (width * height) << 2; - break; - default: - /* unsupported format */ - DBG_INFO(80, "Error: cannot get size. unsupported gfmt:%x\n", format); - ; - } - - return dataSize; -} - -#if 0 /* unused */ -uint32 -TxUtil::chkAlpha(uint32* src, int width, int height) -{ - /* NOTE: _src must be ARGB8888 - * return values - * 0x00000000: 8bit alpha - * 0x00000001: 1bit alpha - * 0xff000001: no alpha - */ - - int _size = width * height; - uint32 alpha = 0; - - __asm { - mov esi, dword ptr [src]; - mov ecx, dword ptr [_size]; - mov ebx, 0xff000000; - - tc1_loop: - mov eax, dword ptr [esi]; - add esi, 4; - - and eax, 0xff000000; - jz alpha1bit; - cmp eax, 0xff000000; - je alpha1bit; - jmp done; - - alpha1bit: - and ebx, eax; - dec ecx; - jnz tc1_loop; - - or ebx, 0x00000001; - mov dword ptr [alpha], ebx; - - done: - } - - return alpha; -} -#endif - -uint32 -TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride) -{ - /* Rice CRC32 for now. We can switch this to Jabo MD5 or - * any other custom checksum. - * TODO: use *_HIRESTEXTURE option. */ - - if (!src) return 0; - - return RiceCRC32(src, width, height, size, rowStride); -} - -uint64 -TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) -{ - /* Rice CRC32 for now. We can switch this to Jabo MD5 or - * any other custom checksum. - * TODO: use *_HIRESTEXTURE option. */ - /* Returned value is 64bits: hi=palette crc32 low=texture crc32 */ - - if (!src) return 0; - - uint64 crc64Ret = 0; - - if (palette) { - uint32 crc32 = 0, cimax = 0; - switch (size & 0xff) { - case 1: - if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax)) { - crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 512); - crc64Ret <<= 32; - crc64Ret |= (uint64)crc32; - } - break; - case 0: - if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax)) { - crc64Ret = (uint64)RiceCRC32(palette, cimax + 1, 1, 2, 32); - crc64Ret <<= 32; - crc64Ret |= (uint64)crc32; - } + /* a lookup table for the shifts would be better */ + switch (format) { + case GFX_TEXFMT_ARGB_CMP_FXT1: + dataSize = (((width + 0x7) & ~0x7) * ((height + 0x3) & ~0x3)) >> 1; + break; + case GFX_TEXFMT_ARGB_CMP_DXT1: + dataSize = (((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3)) >> 1; + break; + case GFX_TEXFMT_ARGB_CMP_DXT3: + case GFX_TEXFMT_ARGB_CMP_DXT5: + dataSize = ((width + 0x3) & ~0x3) * ((height + 0x3) & ~0x3); + break; + case GFX_TEXFMT_ALPHA_INTENSITY_44: + case GFX_TEXFMT_ALPHA_8: + case GFX_TEXFMT_INTENSITY_8: + case GFX_TEXFMT_P_8: + dataSize = width * height; + break; + case GFX_TEXFMT_ARGB_4444: + case GFX_TEXFMT_ARGB_1555: + case GFX_TEXFMT_RGB_565: + case GFX_TEXFMT_ALPHA_INTENSITY_88: + dataSize = (width * height) << 1; + break; + case GFX_TEXFMT_ARGB_8888: + dataSize = (width * height) << 2; + break; + default: + /* unsupported format */ + DBG_INFO(80, "Error: cannot get size. unsupported gfmt:%x\n", format); + ; } - } - if (!crc64Ret) { - crc64Ret = (uint64)RiceCRC32(src, width, height, size, rowStride); - } - return crc64Ret; + return dataSize; +} + +uint32 TxUtil::checksum(uint8 *src, int width, int height, int size, int rowStride) +{ + /* Rice CRC32 for now. We can switch this to Jabo MD5 or + * any other custom checksum. + * TODO: use *_HIRESTEXTURE option. */ + + if (!src) return 0; + + return RiceCRC32(src, width, height, size, rowStride); +} + +uint64_t TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette) +{ + /* Rice CRC32 for now. We can switch this to Jabo MD5 or + * any other custom checksum. + * TODO: use *_HIRESTEXTURE option. */ + /* Returned value is 64bits: hi=palette crc32 low=texture crc32 */ + + if (!src) return 0; + + uint64_t crc64Ret = 0; + + if (palette) + { + uint32 crc32 = 0, cimax = 0; + switch (size & 0xff) + { + case 1: + if (RiceCRC32_CI8(src, width, height, size, rowStride, &crc32, &cimax)) + { + crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 512); + crc64Ret <<= 32; + crc64Ret |= (uint64_t)crc32; + } + break; + case 0: + if (RiceCRC32_CI4(src, width, height, size, rowStride, &crc32, &cimax)) + { + crc64Ret = (uint64_t)RiceCRC32(palette, cimax + 1, 1, 2, 32); + crc64Ret <<= 32; + crc64Ret |= (uint64_t)crc32; + } + } + } + if (!crc64Ret) + { + crc64Ret = (uint64_t)RiceCRC32(src, width, height, size, rowStride); + } + + return crc64Ret; } /* @@ -242,7 +169,7 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u ** 65521. s1 is initialized to 1, s2 to zero. The Adler-32 checksum is stored ** as s2*65536 + s1 in most-significant-byte first (network) order. ** -** 8.2. The Adler-32 algorithm +** 8.2. The Adler-32 algorithm ** ** The Adler-32 algorithm is much faster than the CRC32 algorithm yet still ** provides an extremely low probability of undetected errors. @@ -261,59 +188,37 @@ TxUtil::checksum64(uint8 *src, int width, int height, int size, int rowStride, u ** separately. (Any sequence of zeroes has a Fletcher checksum of zero.) */ -uint32 -TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32) +uint32 TxUtil::Adler32(const uint8* data, int Len, uint32 dwAdler32) { -#if 1 - /* zlib adler32 */ - return adler32(dwAdler32, data, Len); -#else - register uint32 s1 = dwAdler32 & 0xFFFF; - register uint32 s2 = (dwAdler32 >> 16) & 0xFFFF; - int k; - - while (Len > 0) { - /* 5552 is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ - k = (Len < 5552 ? Len : 5552); - Len -= k; - while (k--) { - s1 += *data++; - s2 += s1; - } - /* 65521 is the largest prime smaller than 65536 */ - s1 %= 65521; - s2 %= 65521; - } - - return (s2 << 16) | s1; -#endif + /* zlib adler32 */ + return adler32(dwAdler32, data, Len); } -uint32 -TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride) +uint32 TxUtil::Adler32(const uint8* src, int width, int height, int size, int rowStride) { - int i; - uint32 ret = 1; - uint32 width_in_bytes = width * size; + int i; + uint32 ret = 1; + uint32 width_in_bytes = width * size; - for (i = 0; i < height; i++) { - ret = Adler32(src, width_in_bytes, ret); - src += rowStride; - } + for (i = 0; i < height; i++) + { + ret = Adler32(src, width_in_bytes, ret); + src += rowStride; + } - return ret; + return ret; } // rotate left template static T __ROL__(T value, unsigned int count) { - const unsigned int nbits = sizeof(T) * 8; - count %= nbits; + const unsigned int nbits = sizeof(T) * 8; + count %= nbits; - T high = value >> (nbits - count); - value <<= count; - value |= high; - return value; + T high = value >> (nbits - count); + value <<= count; + value |= high; + return value; } /* Rice CRC32 for hires texture packs */ @@ -321,154 +226,156 @@ template static T __ROL__(T value, unsigned int count) * for Rice hires texture packs. * * BYTE* addr = (BYTE*)(gfx.RDRAM + - * rdp.addr[rdp.tiles[tile].t_mem] + - * (rdp.tiles[tile].ul_t * bpl) + - * (((rdp.tiles[tile].ul_s<>1)); + * rdp.addr[rdp.tiles(tile).t_mem] + + * (rdp.tiles(tile).ul_t * bpl) + + * (((rdp.tiles(tile).ul_s<>1)); * RiceCRC32(addr, - * rdp.tiles[tile].width, - * rdp.tiles[tile].height, - * (unsigned short)(rdp.tiles[tile].format << 8 | rdp.tiles[tile].size), + * rdp.tiles(tile).width, + * rdp.tiles(tile).height, + * (unsigned short)(rdp.tiles(tile).format << 8 | rdp.tiles(tile).size), * bpl); */ -uint32 -TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride) +uint32 TxUtil::RiceCRC32(const uint8* src, int width, int height, int size, int rowStride) { - const uint8_t *row; - uint32_t crc32Ret; - int cur_height; - uint32_t pos; - uint32_t word; - uint32_t word_hash = 0; - uint32_t tmp; - const uint32_t bytes_per_width = ((width << size) + 1) >> 1; + const uint8_t *row; + uint32_t crc32Ret; + int cur_height; + uint32_t pos; + uint32_t word; + uint32_t word_hash = 0; + uint32_t tmp; + const uint32_t bytes_per_width = ((width << size) + 1) >> 1; - row = src; - crc32Ret = 0; + row = src; + crc32Ret = 0; - for (cur_height = height - 1; cur_height >= 0; cur_height--) { - for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { - word = *(uint32_t *)&row[pos]; - word_hash = pos ^ word; - tmp = __ROL__(crc32Ret, 4); - crc32Ret = word_hash + tmp; + for (cur_height = height - 1; cur_height >= 0; cur_height--) + { + for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) + { + word = *(uint32_t *)&row[pos]; + word_hash = pos ^ word; + tmp = __ROL__(crc32Ret, 4); + crc32Ret = word_hash + tmp; + } + crc32Ret += cur_height ^ word_hash; + row += rowStride; } - crc32Ret += cur_height ^ word_hash; - row += rowStride; - } - return crc32Ret; + return crc32Ret; } -boolean -TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, - uint32* crc32, uint32* cimax) +bool TxUtil::RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax) { - const uint8_t *row; - uint32_t crc32Ret; - uint32_t cimaxRet; - int cur_height; - uint32_t pos; - uint32_t word; - uint32_t word_hash = 0; - uint32_t tmp; - const uint32_t bytes_per_width = ((width << size) + 1) >> 1; + const uint8_t *row; + uint32_t crc32Ret; + uint32_t cimaxRet; + int cur_height; + uint32_t pos; + uint32_t word; + uint32_t word_hash = 0; + uint32_t tmp; + const uint32_t bytes_per_width = ((width << size) + 1) >> 1; - row = src; - crc32Ret = 0; - cimaxRet = 0; + row = src; + crc32Ret = 0; + cimaxRet = 0; - for (cur_height = height - 1; cur_height >= 0; cur_height--) { - for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { - word = *(uint32_t *)&row[pos]; - if (cimaxRet != 15) { - if ((word & 0xF) >= cimaxRet) - cimaxRet = word & 0xF; - if ((uint32_t)((uint8_t)word >> 4) >= cimaxRet) - cimaxRet = (uint8_t)word >> 4; - if (((word >> 8) & 0xF) >= cimaxRet) - cimaxRet = (word >> 8) & 0xF; - if ((uint32_t)((uint16_t)word >> 12) >= cimaxRet) - cimaxRet = (uint16_t)word >> 12; - if (((word >> 16) & 0xF) >= cimaxRet) - cimaxRet = (word >> 16) & 0xF; - if (((word >> 20) & 0xF) >= cimaxRet) - cimaxRet = (word >> 20) & 0xF; - if (((word >> 24) & 0xF) >= cimaxRet) - cimaxRet = (word >> 24) & 0xF; - if (word >> 28 >= cimaxRet ) - cimaxRet = word >> 28; - } - word_hash = pos ^ word; - tmp = __ROL__(crc32Ret, 4); - crc32Ret = word_hash + tmp; + for (cur_height = height - 1; cur_height >= 0; cur_height--) + { + for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) + { + word = *(uint32_t *)&row[pos]; + if (cimaxRet != 15) + { + if ((word & 0xF) >= cimaxRet) + cimaxRet = word & 0xF; + if ((uint32_t)((uint8_t)word >> 4) >= cimaxRet) + cimaxRet = (uint8_t)word >> 4; + if (((word >> 8) & 0xF) >= cimaxRet) + cimaxRet = (word >> 8) & 0xF; + if ((uint32_t)((uint16_t)word >> 12) >= cimaxRet) + cimaxRet = (uint16_t)word >> 12; + if (((word >> 16) & 0xF) >= cimaxRet) + cimaxRet = (word >> 16) & 0xF; + if (((word >> 20) & 0xF) >= cimaxRet) + cimaxRet = (word >> 20) & 0xF; + if (((word >> 24) & 0xF) >= cimaxRet) + cimaxRet = (word >> 24) & 0xF; + if (word >> 28 >= cimaxRet) + cimaxRet = word >> 28; + } + word_hash = pos ^ word; + tmp = __ROL__(crc32Ret, 4); + crc32Ret = word_hash + tmp; + } + crc32Ret += cur_height ^ word_hash; + row += rowStride; } - crc32Ret += cur_height ^ word_hash; - row += rowStride; - } - *crc32 = crc32Ret; - *cimax = cimaxRet; - return 1; + *crc32 = crc32Ret; + *cimax = cimaxRet; + return 1; } -boolean -TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, - uint32* crc32, uint32* cimax) +bool TxUtil::RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, uint32* crc32, uint32* cimax) { - const uint8_t *row; - uint32_t crc32Ret; - uint32_t cimaxRet; - int cur_height; - uint32_t pos; - uint32_t word; - uint32_t word_hash = 0; - uint32_t tmp; - const uint32_t bytes_per_width = ((width << size) + 1) >> 1; + const uint8_t *row; + uint32_t crc32Ret; + uint32_t cimaxRet; + int cur_height; + uint32_t pos; + uint32_t word; + uint32_t word_hash = 0; + uint32_t tmp; + const uint32_t bytes_per_width = ((width << size) + 1) >> 1; - row = src; - crc32Ret = 0; - cimaxRet = 0; + row = src; + crc32Ret = 0; + cimaxRet = 0; - for (cur_height = height - 1; cur_height >= 0; cur_height--) { - for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) { - word = *(uint32_t *)&row[pos]; - if (cimaxRet != 255) { - if ((uint8_t)word >= cimaxRet) - cimaxRet = (uint8_t)word; - if ((uint32_t)((uint16_t)word >> 8) >= cimaxRet) - cimaxRet = (uint16_t)word >> 8; - if (((word >> 16) & 0xFF) >= cimaxRet) - cimaxRet = (word >> 16) & 0xFF; - if (word >> 24 >= cimaxRet) - cimaxRet = word >> 24; - } - word_hash = pos ^ word; - tmp = __ROL__(crc32Ret, 4); - crc32Ret = word_hash + tmp; + for (cur_height = height - 1; cur_height >= 0; cur_height--) + { + for (pos = bytes_per_width - 4; pos < 0x80000000u; pos -= 4) + { + word = *(uint32_t *)&row[pos]; + if (cimaxRet != 255) + { + if ((uint8_t)word >= cimaxRet) + cimaxRet = (uint8_t)word; + if ((uint32_t)((uint16_t)word >> 8) >= cimaxRet) + cimaxRet = (uint16_t)word >> 8; + if (((word >> 16) & 0xFF) >= cimaxRet) + cimaxRet = (word >> 16) & 0xFF; + if (word >> 24 >= cimaxRet) + cimaxRet = word >> 24; + } + word_hash = pos ^ word; + tmp = __ROL__(crc32Ret, 4); + crc32Ret = word_hash + tmp; + } + crc32Ret += cur_height ^ word_hash; + row += rowStride; } - crc32Ret += cur_height ^ word_hash; - row += rowStride; - } - *crc32 = crc32Ret; - *cimax = cimaxRet; - return 1; + *crc32 = crc32Ret; + *cimax = cimaxRet; + return 1; } -int -TxUtil::log2(int num) +int TxUtil::log2(int num) { #if defined(__GNUC__) - return __builtin_ctz(num); + return __builtin_ctz(num); #elif defined(_MSC_VER) && _MSC_VER >= 1400 - uint32_t i; - _BitScanForward((DWORD *)&i, num); - return i; + uint32_t i; + _BitScanForward((unsigned long *)&i, num); + return i; #elif defined(__MSC__) - __asm { - mov eax, dword ptr [num]; - bsr eax, eax; - mov dword ptr [i], eax; - } + __asm { + mov eax, dword ptr[num]; + bsr eax, eax; + mov dword ptr[i], eax; + } #else - switch (num) { + switch (num) { case 1: return 0; case 2: return 1; case 4: return 2; @@ -481,104 +388,99 @@ TxUtil::log2(int num) case 512: return 9; case 1024: return 10; case 2048: return 11; - } + } #endif } -int -TxUtil::grLodLog2(int w, int h) +int TxUtil::grLodLog2(int w, int h) { - return (w >= h ? log2(w) : log2(h)); + return (w >= h ? log2(w) : log2(h)); } -int -TxUtil::grAspectRatioLog2(int w, int h) +int TxUtil::grAspectRatioLog2(int w, int h) { - return (w >= h ? log2(w/h) : -log2(h/w)); + return (w >= h ? log2(w / h) : -log2(h / w)); } -int -TxUtil::getNumberofProcessors() +int TxUtil::getNumberofProcessors() { - int numcore = 1, ret; + int numcore = 1, ret; #ifdef _WIN32 #ifndef _SC_NPROCESSORS_ONLN - SYSTEM_INFO info; - GetSystemInfo(&info); + SYSTEM_INFO info; + GetSystemInfo(&info); #define sysconf(a) info.dwNumberOfProcessors #define _SC_NPROCESSORS_ONLN #endif #endif #ifdef _SC_NPROCESSORS_ONLN - ret = sysconf(_SC_NPROCESSORS_CONF); - if (ret >= 1) { - numcore = ret; - } - ret = sysconf(_SC_NPROCESSORS_ONLN); - if (ret < 1) { - numcore = ret; - } + ret = sysconf(_SC_NPROCESSORS_CONF); + if (ret >= 1) { + numcore = ret; + } + ret = sysconf(_SC_NPROCESSORS_ONLN); + if (ret < 1) { + numcore = ret; + } #endif - return numcore; + return numcore; } - /* * Memory buffers for texture manipulations ******************************************************************************/ TxMemBuf::TxMemBuf() { - int i; - for (i = 0; i < 2; i++) { - _tex[i] = NULL; - _size[i] = 0; - } + int i; + for (i = 0; i < 2; i++) { + _tex[i] = NULL; + _size[i] = 0; + } } TxMemBuf::~TxMemBuf() { - shutdown(); + shutdown(); } -boolean -TxMemBuf::init(int maxwidth, int maxheight) +bool TxMemBuf::init(int maxwidth, int maxheight) { - int i; - for (i = 0; i < 2; i++) { - if (!_tex[i]) { - _tex[i] = (uint8 *)malloc(maxwidth * maxheight * 4); - _size[i] = maxwidth * maxheight * 4; + int i; + for (i = 0; i < 2; i++) + { + if (!_tex[i]) + { + _tex[i] = (uint8 *)malloc(maxwidth * maxheight * 4); + _size[i] = maxwidth * maxheight * 4; + } + + if (!_tex[i]) + { + shutdown(); + return 0; + } } + return 1; +} - if (!_tex[i]) { - shutdown(); - return 0; +void TxMemBuf::shutdown() +{ + int i; + for (i = 0; i < 2; i++) { + if (_tex[i]) free(_tex[i]); + _tex[i] = NULL; + _size[i] = 0; } - } - return 1; } -void -TxMemBuf::shutdown() +uint8* TxMemBuf::get(unsigned int num) { - int i; - for (i = 0; i < 2; i++) { - if (_tex[i]) free(_tex[i]); - _tex[i] = NULL; - _size[i] = 0; - } + return ((num < 2) ? _tex[num] : NULL); } -uint8* -TxMemBuf::get(unsigned int num) +uint32 TxMemBuf::size_of(unsigned int num) { - return ((num < 2) ? _tex[num] : NULL); -} - -uint32 -TxMemBuf::size_of(unsigned int num) -{ - return ((num < 2) ? _size[num] : 0); -} + return ((num < 2) ? _size[num] : 0); +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/TxUtil.h b/Source/Project64-video/TextureEnhancer/TxUtil.h index b89f660df..868bf5662 100644 --- a/Source/Project64-video/TextureEnhancer/TxUtil.h +++ b/Source/Project64-video/TextureEnhancer/TxUtil.h @@ -1,25 +1,16 @@ -/* - * Texture Filtering - * Version: 1.0 - * - * Copyright (C) 2007 Hiroshi Morii All Rights Reserved. - * Email koolsmoky(at)users.sourceforge.net - * Web http://www.3dfxzone.it/koolsmoky - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2003 Rice1964 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef __TXUTIL_H__ #define __TXUTIL_H__ @@ -30,92 +21,87 @@ #include "TxInternal.h" #include -#ifndef DXTN_DLL #ifdef __cplusplus -extern "C"{ +extern "C" { #endif -void tx_compress_dxtn(int srccomps, int width, int height, - const void *source, int destformat, void *dest, - int destRowStride); + void tx_compress_dxtn(int srccomps, int width, int height, + const void *source, int destformat, void *dest, + int destRowStride); -int fxt1_encode(int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); + int fxt1_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); #ifdef __cplusplus } #endif -#endif /* DXTN_DLL */ -typedef void (*dxtCompressTexFuncExt)(int srccomps, int width, - int height, const void *srcPixData, - int destformat, void *dest, - int dstRowStride); +typedef void(*dxtCompressTexFuncExt)(int srccomps, int width, + int height, const void *srcPixData, + int destformat, void *dest, + int dstRowStride); -typedef int (*fxtCompressTexFuncExt)(int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +typedef int(*fxtCompressTexFuncExt)(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); class TxLoadLib { private: -#ifdef DXTN_DLL - HMODULE _dxtnlib; -#endif - fxtCompressTexFuncExt _tx_compress_fxt1; - dxtCompressTexFuncExt _tx_compress_dxtn; - TxLoadLib(); + fxtCompressTexFuncExt _tx_compress_fxt1; + dxtCompressTexFuncExt _tx_compress_dxtn; + TxLoadLib(); public: - static TxLoadLib* getInstance() { - static TxLoadLib txLoadLib; - return &txLoadLib; - } - ~TxLoadLib(); - fxtCompressTexFuncExt getfxtCompressTexFuncExt(); - dxtCompressTexFuncExt getdxtCompressTexFuncExt(); + static TxLoadLib* getInstance() { + static TxLoadLib txLoadLib; + return &txLoadLib; + } + ~TxLoadLib(); + fxtCompressTexFuncExt getfxtCompressTexFuncExt(); + dxtCompressTexFuncExt getdxtCompressTexFuncExt(); }; class TxUtil { private: - uint32 Adler32(const uint8* data, int Len, uint32 Adler); - uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride); - uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride); - boolean RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, - uint32* crc32, uint32* cimax); - boolean RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, - uint32* crc32, uint32* cimax); - int log2(int num); + uint32 Adler32(const uint8* data, int Len, uint32 Adler); + uint32 Adler32(const uint8* src, int width, int height, int size, int rowStride); + uint32 RiceCRC32(const uint8* src, int width, int height, int size, int rowStride); + bool RiceCRC32_CI4(const uint8* src, int width, int height, int size, int rowStride, + uint32* crc32, uint32* cimax); + bool RiceCRC32_CI8(const uint8* src, int width, int height, int size, int rowStride, + uint32* crc32, uint32* cimax); + int log2(int num); public: - TxUtil() { } - ~TxUtil() { } - int sizeofTx(int width, int height, uint16 format); - uint32 checksumTx(uint8 *data, int width, int height, uint16 format); + TxUtil() { } + ~TxUtil() { } + int sizeofTx(int width, int height, uint16 format); + uint32 checksumTx(uint8 *data, int width, int height, uint16 format); #if 0 /* unused */ - uint32 chkAlpha(uint32* src, int width, int height); + uint32 chkAlpha(uint32* src, int width, int height); #endif - uint32 checksum(uint8 *src, int width, int height, int size, int rowStride); - uint64 checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); - int grLodLog2(int w, int h); - int grAspectRatioLog2(int w, int h); - int getNumberofProcessors(); + uint32 checksum(uint8 *src, int width, int height, int size, int rowStride); + uint64_t checksum64(uint8 *src, int width, int height, int size, int rowStride, uint8 *palette); + int grLodLog2(int w, int h); + int grAspectRatioLog2(int w, int h); + int getNumberofProcessors(); }; class TxMemBuf { private: - uint8 *_tex[2]; - uint32 _size[2]; - TxMemBuf(); + uint8 *_tex[2]; + uint32 _size[2]; + TxMemBuf(); public: - static TxMemBuf* getInstance() { - static TxMemBuf txMemBuf; - return &txMemBuf; - } - ~TxMemBuf(); - boolean init(int maxwidth, int maxheight); - void shutdown(void); - uint8 *get(unsigned int num); - uint32 size_of(unsigned int num); + static TxMemBuf* getInstance() { + static TxMemBuf txMemBuf; + return &txMemBuf; + } + ~TxMemBuf(); + bool init(int maxwidth, int maxheight); + void shutdown(void); + uint8 *get(unsigned int num); + uint32 size_of(unsigned int num); }; #endif /* __TXUTIL_H__ */ diff --git a/Source/Project64-video/TextureEnhancer/bldno.h b/Source/Project64-video/TextureEnhancer/bldno.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c index e2d335ae0..8f0e2da8c 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.c @@ -1,29 +1,16 @@ -/* - * DXTn codec - * Version: 1.1 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* Copyright (C) 2007 Hiroshi Morii - * Added support for ARGB inputs, DXT3,5 workaround for ATI Radeons, and - * YUV conversions to determine representative colors. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include @@ -35,7 +22,6 @@ #include "internal.h" #include "dxtn.h" - /***************************************************************************\ * DXTn encoder * @@ -44,13 +30,11 @@ * is merely a proof of concept, since it is highly UNoptimized! \***************************************************************************/ - #define MAX_COMP 4 /* ever needed maximum number of components in texel */ #define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ #define N_TEXELS 16 /* number of texels in a block (always 16) */ #define COLOR565(v) (word)((((v)[RCOMP] & 0xf8) << 8) | (((v)[GCOMP] & 0xfc) << 3) | ((v)[BCOMP] >> 3)) - static const int dxtn_color_tlat[2][4] = { { 0, 2, 3, 1 }, { 0, 2, 1, 3 } @@ -61,9 +45,8 @@ static const int dxtn_alpha_tlat[2][8] = { { 0, 2, 3, 4, 5, 1, 6, 7 } }; - static void -dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps) +dxt1_rgb_quantize(dword *cc, const byte *lines[], int comps) { float b, iv[MAX_COMP]; /* interpolation vector */ @@ -91,21 +74,21 @@ dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps) /* 4 texels each line */ #ifndef ARGB for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } } #else /* H.Morii - support for ARGB inputs */ for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - input[k + l * 4][2] = *lines[l]++; - input[k + l * 4][1] = *lines[l]++; - input[k + l * 4][0] = *lines[l]++; - if (comps == 4) input[k + l * 4][3] = *lines[l]++; - } + for (k = 0; k < 4; k++) { + input[k + l * 4][2] = *lines[l]++; + input[k + l * 4][1] = *lines[l]++; + input[k + l * 4][0] = *lines[l]++; + if (comps == 4) input[k + l * 4][3] = *lines[l]++; + } } #endif @@ -114,85 +97,85 @@ dxt1_rgb_quantize (dword *cc, const byte *lines[], int comps) * There are probably better algorithms to use (histogram-based). */ for (k = 0; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else /* RGB to YUV conversion according to CCIR 601 specs * Y = 0.299R+0.587G+0.114B * U = 0.713(R - Y) = 0.500R-0.419G-0.081B * V = 0.564(B - Y) = -0.169R-0.331G+0.500B */ - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } - if (sum == 0) { - black = 1; - } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } + if (sum == 0) { + black = 1; + } } color0 = COLOR565(input[minCol]); color1 = COLOR565(input[maxCol]); if (color0 == color1) { - /* we'll use 3-vector */ - cc[0] = color0 | (color1 << 16); - hi = black ? -1 : 0; - } else { - if (black && ((color0 == 0) || (color1 == 0))) { - /* we still can use 4-vector */ - black = 0; - } + /* we'll use 3-vector */ + cc[0] = color0 | (color1 << 16); + hi = black ? -1 : 0; + } + else { + if (black && ((color0 == 0) || (color1 == 0))) { + /* we still can use 4-vector */ + black = 0; + } - if (black ^ (color0 <= color1)) { - int aux; - aux = color0; - color0 = color1; - color1 = aux; - aux = minCol; - minCol = maxCol; - maxCol = aux; - } - n_vect = (color0 <= color1) ? 2 : 3; + if (black ^ (color0 <= color1)) { + int aux; + aux = color0; + color0 = color1; + color1 = aux; + aux = minCol; + minCol = maxCol; + maxCol = aux; + } + n_vect = (color0 <= color1) ? 2 : 3; - MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); + MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ - cc[0] = color0 | (color1 << 16); - hi = 0; - for (k = N_TEXELS - 1; k >= 0; k--) { - int texel = 3; - int sum = 0; - if (black) { - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } - } - if (!black || sum) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - texel = dxtn_color_tlat[black][texel]; - } - /* add in texel */ - hi <<= 2; - hi |= texel; - } + /* add in texels */ + cc[0] = color0 | (color1 << 16); + hi = 0; + for (k = N_TEXELS - 1; k >= 0; k--) { + int texel = 3; + int sum = 0; + if (black) { + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } + } + if (!black || sum) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + texel = dxtn_color_tlat[black][texel]; + } + /* add in texel */ + hi <<= 2; + hi |= texel; + } } cc[1] = hi; } - static void -dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps) +dxt1_rgba_quantize(dword *cc, const byte *lines[], int comps) { float b, iv[MAX_COMP]; /* interpolation vector */ @@ -215,28 +198,28 @@ dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps) int i, k, l; if (comps == 3) { - /* make the whole block opaque */ - memset(input, -1, sizeof(input)); + /* make the whole block opaque */ + memset(input, -1, sizeof(input)); } /* 4 texels each line */ #ifndef ARGB for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } } #else /* H.Morii - support for ARGB inputs */ for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - input[k + l * 4][2] = *lines[l]++; - input[k + l * 4][1] = *lines[l]++; - input[k + l * 4][0] = *lines[l]++; - if (comps == 4) input[k + l * 4][3] = *lines[l]++; - } + for (k = 0; k < 4; k++) { + input[k + l * 4][2] = *lines[l]++; + input[k + l * 4][1] = *lines[l]++; + input[k + l * 4][0] = *lines[l]++; + if (comps == 4) input[k + l * 4][3] = *lines[l]++; + } } #endif @@ -245,69 +228,69 @@ dxt1_rgba_quantize (dword *cc, const byte *lines[], int comps) * There are probably better algorithms to use (histogram-based). */ for (k = 0; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } - if (input[k][ACOMP] < 128) { - transparent = 1; - } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } + if (input[k][ACOMP] < 128) { + transparent = 1; + } } color0 = COLOR565(input[minCol]); color1 = COLOR565(input[maxCol]); if (color0 == color1) { - /* we'll use 3-vector */ - cc[0] = color0 | (color1 << 16); - hi = transparent ? -1 : 0; - } else { - if (transparent ^ (color0 <= color1)) { - int aux; - aux = color0; - color0 = color1; - color1 = aux; - aux = minCol; - minCol = maxCol; - maxCol = aux; - } - n_vect = (color0 <= color1) ? 2 : 3; + /* we'll use 3-vector */ + cc[0] = color0 | (color1 << 16); + hi = transparent ? -1 : 0; + } + else { + if (transparent ^ (color0 <= color1)) { + int aux; + aux = color0; + color0 = color1; + color1 = aux; + aux = minCol; + minCol = maxCol; + maxCol = aux; + } + n_vect = (color0 <= color1) ? 2 : 3; - MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); + MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ - cc[0] = color0 | (color1 << 16); - hi = 0; - for (k = N_TEXELS - 1; k >= 0; k--) { - int texel = 3; - if (input[k][ACOMP] >= 128) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - texel = dxtn_color_tlat[transparent][texel]; - } - /* add in texel */ - hi <<= 2; - hi |= texel; - } + /* add in texels */ + cc[0] = color0 | (color1 << 16); + hi = 0; + for (k = N_TEXELS - 1; k >= 0; k--) { + int texel = 3; + if (input[k][ACOMP] >= 128) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + texel = dxtn_color_tlat[transparent][texel]; + } + /* add in texel */ + hi <<= 2; + hi |= texel; + } } cc[1] = hi; } - static void -dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps) +dxt3_rgba_quantize(dword *cc, const byte *lines[], int comps) { float b, iv[MAX_COMP]; /* interpolation vector */ @@ -330,28 +313,28 @@ dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps) int i, k, l; if (comps == 3) { - /* make the whole block opaque */ - memset(input, -1, sizeof(input)); + /* make the whole block opaque */ + memset(input, -1, sizeof(input)); } /* 4 texels each line */ #ifndef ARGB for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } } #else /* H.Morii - support for ARGB inputs */ for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - input[k + l * 4][2] = *lines[l]++; - input[k + l * 4][1] = *lines[l]++; - input[k + l * 4][0] = *lines[l]++; - if (comps == 4) input[k + l * 4][3] = *lines[l]++; - } + for (k = 0; k < 4; k++) { + input[k + l * 4][2] = *lines[l]++; + input[k + l * 4][1] = *lines[l]++; + input[k + l * 4][0] = *lines[l]++; + if (comps == 4) input[k + l * 4][3] = *lines[l]++; + } } #endif @@ -360,36 +343,36 @@ dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps) * There are probably better algorithms to use (histogram-based). */ for (k = 0; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } } /* add in alphas */ lolo = lohi = 0; for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - /* add in alpha */ - lohi <<= 4; - lohi |= input[k][ACOMP] >> 4; + /* add in alpha */ + lohi <<= 4; + lohi |= input[k][ACOMP] >> 4; } cc[1] = lohi; for (; k >= 0; k--) { - /* add in alpha */ - lolo <<= 4; - lolo |= input[k][ACOMP] >> 4; + /* add in alpha */ + lolo <<= 4; + lolo |= input[k][ACOMP] >> 4; } cc[0] = lolo; @@ -406,13 +389,13 @@ dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps) * be color0 > color1. */ if (color0 < color1) { - int aux; - aux = color0; - color0 = color1; - color1 = aux; - aux = minCol; - minCol = maxCol; - maxCol = aux; + int aux; + aux = color0; + color0 = color1; + color1 = aux; + aux = minCol; + minCol = maxCol; + maxCol = aux; } #endif @@ -420,25 +403,24 @@ dxt3_rgba_quantize (dword *cc, const byte *lines[], int comps) hihi = 0; if (color0 != color1) { - MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); + MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ - for (k = N_TEXELS - 1; k >= 0; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - texel = dxtn_color_tlat[0][texel]; - /* add in texel */ - hihi <<= 2; - hihi |= texel; - } + /* add in texels */ + for (k = N_TEXELS - 1; k >= 0; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + texel = dxtn_color_tlat[0][texel]; + /* add in texel */ + hihi <<= 2; + hihi |= texel; + } } cc[3] = hihi; } - static void -dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps) +dxt5_rgba_quantize(dword *cc, const byte *lines[], int comps) { float b, iv[MAX_COMP]; /* interpolation vector */ @@ -465,28 +447,28 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps) int i, k, l; if (comps == 3) { - /* make the whole block opaque */ - memset(input, -1, sizeof(input)); + /* make the whole block opaque */ + memset(input, -1, sizeof(input)); } /* 4 texels each line */ #ifndef ARGB for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } } #else /* H.Morii - support for ARGB inputs */ for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - input[k + l * 4][2] = *lines[l]++; - input[k + l * 4][1] = *lines[l]++; - input[k + l * 4][0] = *lines[l]++; - if (comps == 4) input[k + l * 4][3] = *lines[l]++; - } + for (k = 0; k < 4; k++) { + input[k + l * 4][2] = *lines[l]++; + input[k + l * 4][1] = *lines[l]++; + input[k + l * 4][0] = *lines[l]++; + if (comps == 4) input[k + l * 4][3] = *lines[l]++; + } } #endif @@ -495,93 +477,96 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps) * There are probably better algorithms to use (histogram-based). */ for (k = 0; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } - if (alpha0 > input[k][ACOMP]) { - alpha0 = input[k][ACOMP]; - } - if (alpha1 < input[k][ACOMP]) { - alpha1 = input[k][ACOMP]; - } - if (input[k][ACOMP] == 0) { - anyZero = 1; - } - if (input[k][ACOMP] == 255) { - anyOne = 1; - } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } + if (alpha0 > input[k][ACOMP]) { + alpha0 = input[k][ACOMP]; + } + if (alpha1 < input[k][ACOMP]) { + alpha1 = input[k][ACOMP]; + } + if (input[k][ACOMP] == 0) { + anyZero = 1; + } + if (input[k][ACOMP] == 255) { + anyOne = 1; + } } /* add in alphas */ if (alpha0 == alpha1) { - /* we'll use 6-vector */ - cc[0] = alpha0 | (alpha1 << 8); - cc[1] = 0; - } else { - if (anyZero && ((alpha0 == 0) || (alpha1 == 0))) { - /* we still might use 8-vector */ - anyZero = 0; - } - if (anyOne && ((alpha0 == 255) || (alpha1 == 255))) { - /* we still might use 8-vector */ - anyOne = 0; - } - if ((anyZero | anyOne) ^ (alpha0 <= alpha1)) { - int aux; - aux = alpha0; - alpha0 = alpha1; - alpha1 = aux; - } - a_vect = (alpha0 <= alpha1) ? 5 : 7; + /* we'll use 6-vector */ + cc[0] = alpha0 | (alpha1 << 8); + cc[1] = 0; + } + else { + if (anyZero && ((alpha0 == 0) || (alpha1 == 0))) { + /* we still might use 8-vector */ + anyZero = 0; + } + if (anyOne && ((alpha0 == 255) || (alpha1 == 255))) { + /* we still might use 8-vector */ + anyOne = 0; + } + if ((anyZero | anyOne) ^ (alpha0 <= alpha1)) { + int aux; + aux = alpha0; + alpha0 = alpha1; + alpha1 = aux; + } + a_vect = (alpha0 <= alpha1) ? 5 : 7; - /* compute interpolation vector */ - iv[ACOMP] = (float)a_vect / (alpha1 - alpha0); - b = -iv[ACOMP] * alpha0 + 0.5F; + /* compute interpolation vector */ + iv[ACOMP] = (float)a_vect / (alpha1 - alpha0); + b = -iv[ACOMP] * alpha0 + 0.5F; - /* add in alphas */ - Q_MOV32(lo, 0); - for (k = N_TEXELS - 1; k >= 0; k--) { - int texel = -1; - if (anyZero | anyOne) { - if (input[k][ACOMP] == 0) { - texel = 6; - } else if (input[k][ACOMP] == 255) { - texel = 7; - } - } - /* interpolate alpha */ - if (texel == -1) { - float dot = input[k][ACOMP] * iv[ACOMP]; - texel = (int)(dot + b); + /* add in alphas */ + Q_MOV32(lo, 0); + for (k = N_TEXELS - 1; k >= 0; k--) { + int texel = -1; + if (anyZero | anyOne) { + if (input[k][ACOMP] == 0) { + texel = 6; + } + else if (input[k][ACOMP] == 255) { + texel = 7; + } + } + /* interpolate alpha */ + if (texel == -1) { + float dot = input[k][ACOMP] * iv[ACOMP]; + texel = (int)(dot + b); #if SAFECDOT - if (texel < 0) { - texel = 0; - } else if (texel > a_vect) { - texel = a_vect; - } + if (texel < 0) { + texel = 0; + } + else if (texel > a_vect) { + texel = a_vect; + } #endif - texel = dxtn_alpha_tlat[anyZero | anyOne][texel]; - } - /* add in texel */ - Q_SHL(lo, 3); - Q_OR32(lo, texel); - } - Q_SHL(lo, 16); - Q_OR32(lo, alpha0 | (alpha1 << 8)); - ((qword *)cc)[0] = lo; + texel = dxtn_alpha_tlat[anyZero | anyOne][texel]; + } + /* add in texel */ + Q_SHL(lo, 3); + Q_OR32(lo, texel); + } + Q_SHL(lo, 16); + Q_OR32(lo, alpha0 | (alpha1 << 8)); + ((qword *)cc)[0] = lo; } color0 = COLOR565(input[minCol]); @@ -589,13 +574,13 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps) #ifdef RADEON /* H.Morii - Workaround for ATI Radeon */ if (color0 < color1) { - int aux; - aux = color0; - color0 = color1; - color1 = aux; - aux = minCol; - minCol = maxCol; - maxCol = aux; + int aux; + aux = color0; + color0 = color1; + color1 = aux; + aux = minCol; + minCol = maxCol; + maxCol = aux; } #endif @@ -603,23 +588,22 @@ dxt5_rgba_quantize (dword *cc, const byte *lines[], int comps) hihi = 0; if (color0 != color1) { - MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); + MAKEIVEC(n_vect, n_comp, iv, b, input[minCol], input[maxCol]); - /* add in texels */ - for (k = N_TEXELS - 1; k >= 0; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - texel = dxtn_color_tlat[0][texel]; - /* add in texel */ - hihi <<= 2; - hihi |= texel; - } + /* add in texels */ + for (k = N_TEXELS - 1; k >= 0; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + texel = dxtn_color_tlat[0][texel]; + /* add in texel */ + hihi <<= 2; + hihi |= texel; + } } cc[3] = hihi; } - #define ENCODER(dxtn, n) \ int TAPIENTRY \ dxtn##_encode (int width, int height, int comps, \ @@ -670,12 +654,11 @@ dxtn##_encode (int width, int height, int comps, \ return 0; \ } -ENCODER(dxt1_rgb, 2) +ENCODER(dxt1_rgb, 2) ENCODER(dxt1_rgba, 2) ENCODER(dxt3_rgba, 4) ENCODER(dxt5_rgba, 4) - /***************************************************************************\ * DXTn decoder * @@ -683,7 +666,6 @@ ENCODER(dxt5_rgba, 4) * specification and serves as a concept for the encoder. \***************************************************************************/ - /* lookup table for scaling 4 bit colors up to 8 bits */ static const byte _rgb_scale_4[] = { 0, 17, 34, 51, 68, 85, 102, 119, @@ -710,175 +692,191 @@ static const byte _rgb_scale_6[] = { 227, 231, 235, 239, 243, 247, 251, 255 }; - #define CC_SEL(cc, which) (((dword *)(cc))[(which) / 32] >> ((which) & 31)) #define UP4(c) _rgb_scale_4[(c) & 15] #define UP5(c) _rgb_scale_5[(c) & 31] #define UP6(c) _rgb_scale_6[(c) & 63] #define ZERO_4UBV(v) *((dword *)(v)) = 0 - void TAPIENTRY -dxt1_rgb_decode_1 (const void *texture, int stride, - int i, int j, byte *rgba) +dxt1_rgb_decode_1(const void *texture, int stride, + int i, int j, byte *rgba) { const byte *src = (const byte *)texture - + ((j / 4) * ((stride + 3) / 4) + i / 4) * 8; + + ((j / 4) * ((stride + 3) / 4) + i / 4) * 8; const int code = (src[4 + (j & 3)] >> ((i & 3) * 2)) & 0x3; if (code == 0) { - rgba[RCOMP] = UP5(CC_SEL(src, 11)); - rgba[GCOMP] = UP6(CC_SEL(src, 5)); - rgba[BCOMP] = UP5(CC_SEL(src, 0)); - } else if (code == 1) { - rgba[RCOMP] = UP5(CC_SEL(src, 27)); - rgba[GCOMP] = UP6(CC_SEL(src, 21)); - rgba[BCOMP] = UP5(CC_SEL(src, 16)); - } else { - const word col0 = src[0] | (src[1] << 8); - const word col1 = src[2] | (src[3] << 8); - if (col0 > col1) { - if (code == 2) { - rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3; - rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3; - rgba[BCOMP] = (UP5(col0 ) * 2 + UP5(col1 )) / 3; - } else { - rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3; - rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3; - rgba[BCOMP] = (UP5(col0 ) + 2 * UP5(col1 )) / 3; - } - } else { - if (code == 2) { - rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2; - rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2; - rgba[BCOMP] = (UP5(col0 ) + UP5(col1 )) / 2; - } else { - ZERO_4UBV(rgba); - } - } + rgba[RCOMP] = UP5(CC_SEL(src, 11)); + rgba[GCOMP] = UP6(CC_SEL(src, 5)); + rgba[BCOMP] = UP5(CC_SEL(src, 0)); + } + else if (code == 1) { + rgba[RCOMP] = UP5(CC_SEL(src, 27)); + rgba[GCOMP] = UP6(CC_SEL(src, 21)); + rgba[BCOMP] = UP5(CC_SEL(src, 16)); + } + else { + const word col0 = src[0] | (src[1] << 8); + const word col1 = src[2] | (src[3] << 8); + if (col0 > col1) { + if (code == 2) { + rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3; + rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3; + rgba[BCOMP] = (UP5(col0) * 2 + UP5(col1)) / 3; + } + else { + rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3; + rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3; + rgba[BCOMP] = (UP5(col0) + 2 * UP5(col1)) / 3; + } + } + else { + if (code == 2) { + rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2; + rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2; + rgba[BCOMP] = (UP5(col0) + UP5(col1)) / 2; + } + else { + ZERO_4UBV(rgba); + } + } } rgba[ACOMP] = 255; } - void TAPIENTRY -dxt1_rgba_decode_1 (const void *texture, int stride, - int i, int j, byte *rgba) +dxt1_rgba_decode_1(const void *texture, int stride, + int i, int j, byte *rgba) { /* Same as rgb_dxt1 above, except alpha=0 if col0<=col1 and code=3. */ const byte *src = (const byte *)texture - + ((j / 4) * ((stride + 3) / 4) + i / 4) * 8; + + ((j / 4) * ((stride + 3) / 4) + i / 4) * 8; const int code = (src[4 + (j & 3)] >> ((i & 3) * 2)) & 0x3; if (code == 0) { - rgba[RCOMP] = UP5(CC_SEL(src, 11)); - rgba[GCOMP] = UP6(CC_SEL(src, 5)); - rgba[BCOMP] = UP5(CC_SEL(src, 0)); - rgba[ACOMP] = 255; - } else if (code == 1) { - rgba[RCOMP] = UP5(CC_SEL(src, 27)); - rgba[GCOMP] = UP6(CC_SEL(src, 21)); - rgba[BCOMP] = UP5(CC_SEL(src, 16)); - rgba[ACOMP] = 255; - } else { - const word col0 = src[0] | (src[1] << 8); - const word col1 = src[2] | (src[3] << 8); - if (col0 > col1) { - if (code == 2) { - rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3; - rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3; - rgba[BCOMP] = (UP5(col0 ) * 2 + UP5(col1 )) / 3; - } else { - rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3; - rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3; - rgba[BCOMP] = (UP5(col0 ) + 2 * UP5(col1 )) / 3; - } - rgba[ACOMP] = 255; - } else { - if (code == 2) { - rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2; - rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2; - rgba[BCOMP] = (UP5(col0 ) + UP5(col1 )) / 2; - rgba[ACOMP] = 255; - } else { - ZERO_4UBV(rgba); - } - } + rgba[RCOMP] = UP5(CC_SEL(src, 11)); + rgba[GCOMP] = UP6(CC_SEL(src, 5)); + rgba[BCOMP] = UP5(CC_SEL(src, 0)); + rgba[ACOMP] = 255; + } + else if (code == 1) { + rgba[RCOMP] = UP5(CC_SEL(src, 27)); + rgba[GCOMP] = UP6(CC_SEL(src, 21)); + rgba[BCOMP] = UP5(CC_SEL(src, 16)); + rgba[ACOMP] = 255; + } + else { + const word col0 = src[0] | (src[1] << 8); + const word col1 = src[2] | (src[3] << 8); + if (col0 > col1) { + if (code == 2) { + rgba[RCOMP] = (UP5(col0 >> 11) * 2 + UP5(col1 >> 11)) / 3; + rgba[GCOMP] = (UP6(col0 >> 5) * 2 + UP6(col1 >> 5)) / 3; + rgba[BCOMP] = (UP5(col0) * 2 + UP5(col1)) / 3; + } + else { + rgba[RCOMP] = (UP5(col0 >> 11) + 2 * UP5(col1 >> 11)) / 3; + rgba[GCOMP] = (UP6(col0 >> 5) + 2 * UP6(col1 >> 5)) / 3; + rgba[BCOMP] = (UP5(col0) + 2 * UP5(col1)) / 3; + } + rgba[ACOMP] = 255; + } + else { + if (code == 2) { + rgba[RCOMP] = (UP5(col0 >> 11) + UP5(col1 >> 11)) / 2; + rgba[GCOMP] = (UP6(col0 >> 5) + UP6(col1 >> 5)) / 2; + rgba[BCOMP] = (UP5(col0) + UP5(col1)) / 2; + rgba[ACOMP] = 255; + } + else { + ZERO_4UBV(rgba); + } + } } } - void TAPIENTRY -dxt3_rgba_decode_1 (const void *texture, int stride, - int i, int j, byte *rgba) +dxt3_rgba_decode_1(const void *texture, int stride, + int i, int j, byte *rgba) { const byte *src = (const byte *)texture - + ((j / 4) * ((stride + 3) / 4) + i / 4) * 16; + + ((j / 4) * ((stride + 3) / 4) + i / 4) * 16; const int code = (src[12 + (j & 3)] >> ((i & 3) * 2)) & 0x3; const dword *cc = (const dword *)(src + 8); if (code == 0) { - rgba[RCOMP] = UP5(CC_SEL(cc, 11)); - rgba[GCOMP] = UP6(CC_SEL(cc, 5)); - rgba[BCOMP] = UP5(CC_SEL(cc, 0)); - } else if (code == 1) { - rgba[RCOMP] = UP5(CC_SEL(cc, 27)); - rgba[GCOMP] = UP6(CC_SEL(cc, 21)); - rgba[BCOMP] = UP5(CC_SEL(cc, 16)); - } else if (code == 2) { - /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ - rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; - rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; - rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; - } else { - rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3; - rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3; - rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3; + rgba[RCOMP] = UP5(CC_SEL(cc, 11)); + rgba[GCOMP] = UP6(CC_SEL(cc, 5)); + rgba[BCOMP] = UP5(CC_SEL(cc, 0)); + } + else if (code == 1) { + rgba[RCOMP] = UP5(CC_SEL(cc, 27)); + rgba[GCOMP] = UP6(CC_SEL(cc, 21)); + rgba[BCOMP] = UP5(CC_SEL(cc, 16)); + } + else if (code == 2) { + /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ + rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; + rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; + rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; + } + else { + rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3; + rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3; + rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3; } rgba[ACOMP] = UP4(src[((j & 3) * 4 + (i & 3)) / 2] >> ((i & 1) * 4)); } - void TAPIENTRY -dxt5_rgba_decode_1 (const void *texture, int stride, - int i, int j, byte *rgba) +dxt5_rgba_decode_1(const void *texture, int stride, + int i, int j, byte *rgba) { const byte *src = (const byte *)texture - + ((j / 4) * ((stride + 3) / 4) + i / 4) * 16; + + ((j / 4) * ((stride + 3) / 4) + i / 4) * 16; const int code = (src[12 + (j & 3)] >> ((i & 3) * 2)) & 0x3; const dword *cc = (const dword *)(src + 8); const byte alpha0 = src[0]; const byte alpha1 = src[1]; const int alphaShift = (((j & 3) * 4) + (i & 3)) * 3 + 16; const int acode = ((alphaShift == 31) - ? CC_SEL(src + 2, alphaShift - 16) - : CC_SEL(src, alphaShift)) & 0x7; + ? CC_SEL(src + 2, alphaShift - 16) + : CC_SEL(src, alphaShift)) & 0x7; if (code == 0) { - rgba[RCOMP] = UP5(CC_SEL(cc, 11)); - rgba[GCOMP] = UP6(CC_SEL(cc, 5)); - rgba[BCOMP] = UP5(CC_SEL(cc, 0)); - } else if (code == 1) { - rgba[RCOMP] = UP5(CC_SEL(cc, 27)); - rgba[GCOMP] = UP6(CC_SEL(cc, 21)); - rgba[BCOMP] = UP5(CC_SEL(cc, 16)); - } else if (code == 2) { - /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ - rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; - rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; - rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; - } else { - rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3; - rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3; - rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3; + rgba[RCOMP] = UP5(CC_SEL(cc, 11)); + rgba[GCOMP] = UP6(CC_SEL(cc, 5)); + rgba[BCOMP] = UP5(CC_SEL(cc, 0)); + } + else if (code == 1) { + rgba[RCOMP] = UP5(CC_SEL(cc, 27)); + rgba[GCOMP] = UP6(CC_SEL(cc, 21)); + rgba[BCOMP] = UP5(CC_SEL(cc, 16)); + } + else if (code == 2) { + /* (col0 * (4 - code) + col1 * (code - 1)) / 3 */ + rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) * 2 + UP5(CC_SEL(cc, 27))) / 3; + rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) * 2 + UP6(CC_SEL(cc, 21))) / 3; + rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) * 2 + UP5(CC_SEL(cc, 16))) / 3; + } + else { + rgba[RCOMP] = (UP5(CC_SEL(cc, 11)) + 2 * UP5(CC_SEL(cc, 27))) / 3; + rgba[GCOMP] = (UP6(CC_SEL(cc, 5)) + 2 * UP6(CC_SEL(cc, 21))) / 3; + rgba[BCOMP] = (UP5(CC_SEL(cc, 0)) + 2 * UP5(CC_SEL(cc, 16))) / 3; } if (acode == 0) { - rgba[ACOMP] = alpha0; - } else if (acode == 1) { - rgba[ACOMP] = alpha1; - } else if (alpha0 > alpha1) { - rgba[ACOMP] = ((8 - acode) * alpha0 + (acode - 1) * alpha1) / 7; - } else if (acode == 6) { - rgba[ACOMP] = 0; - } else if (acode == 7) { - rgba[ACOMP] = 255; - } else { - rgba[ACOMP] = ((6 - acode) * alpha0 + (acode - 1) * alpha1) / 5; + rgba[ACOMP] = alpha0; + } + else if (acode == 1) { + rgba[ACOMP] = alpha1; + } + else if (alpha0 > alpha1) { + rgba[ACOMP] = ((8 - acode) * alpha0 + (acode - 1) * alpha1) / 7; + } + else if (acode == 6) { + rgba[ACOMP] = 0; + } + else if (acode == 7) { + rgba[ACOMP] = 255; + } + else { + rgba[ACOMP] = ((6 - acode) * alpha0 + (acode - 1) * alpha1) / 5; } } diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h index 4078fd9f9..4722f4d8e 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/dxtn.h @@ -1,62 +1,54 @@ -/* - * DXTn codec - * Version: 1.1 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef DXTN_H_included #define DXTN_H_included TAPI int TAPIENTRY -dxt1_rgb_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +dxt1_rgb_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); TAPI int TAPIENTRY -dxt1_rgba_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +dxt1_rgba_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); TAPI int TAPIENTRY -dxt3_rgba_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +dxt3_rgba_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); TAPI int TAPIENTRY -dxt5_rgba_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +dxt5_rgba_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); TAPI void TAPIENTRY -dxt1_rgb_decode_1 (const void *texture, int stride /* in pixels */, - int i, int j, byte *rgba); +dxt1_rgb_decode_1(const void *texture, int stride /* in pixels */, + int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt1_rgba_decode_1 (const void *texture, int stride /* in pixels */, - int i, int j, byte *rgba); +dxt1_rgba_decode_1(const void *texture, int stride /* in pixels */, + int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt3_rgba_decode_1 (const void *texture, int stride /* in pixels */, - int i, int j, byte *rgba); +dxt3_rgba_decode_1(const void *texture, int stride /* in pixels */, + int i, int j, byte *rgba); TAPI void TAPIENTRY -dxt5_rgba_decode_1 (const void *texture, int stride /* in pixels */, - int i, int j, byte *rgba); +dxt5_rgba_decode_1(const void *texture, int stride /* in pixels */, + int i, int j, byte *rgba); #endif diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c index 88db25097..b92741549 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.c @@ -1,31 +1,16 @@ -/* - * FXT1 codec - * Version: 1.1 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * 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 - * DANIEL BORCA 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. - */ - -/* Copyright (C) 2007 Hiroshi Morii - * Added support for ARGB inputs. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include @@ -34,7 +19,6 @@ #include "internal.h" #include "fxt1.h" - /***************************************************************************\ * FXT1 encoder * @@ -45,7 +29,6 @@ * to Lloyd's algorithm (the interpolation modes are even worse). \***************************************************************************/ - #define MAX_COMP 4 /* ever needed maximum number of components in texel */ #define MAX_VECT 4 /* ever needed maximum number of base vectors to find */ #define N_TEXELS 32 /* number of texels in a block (always 32) */ @@ -56,54 +39,51 @@ #define ISTBLACK(v) (*((dword *)(v)) == 0) #define COPY_4UBV(DST, SRC) *((dword *)(DST)) = *((dword *)(SRC)) - static int -fxt1_bestcol (float vec[][MAX_COMP], int nv, - byte input[MAX_COMP], int nc) +fxt1_bestcol(float vec[][MAX_COMP], int nv, + byte input[MAX_COMP], int nc) { int i, j, best = -1; float err = 1e9; /* big enough */ for (j = 0; j < nv; j++) { - float e = 0.0F; - for (i = 0; i < nc; i++) { - e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]); - } - if (e < err) { - err = e; - best = j; - } + float e = 0.0F; + for (i = 0; i < nc; i++) { + e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]); + } + if (e < err) { + err = e; + best = j; + } } return best; } - static int -fxt1_worst (float vec[MAX_COMP], - byte input[N_TEXELS][MAX_COMP], int nc, int n) +fxt1_worst(float vec[MAX_COMP], + byte input[N_TEXELS][MAX_COMP], int nc, int n) { int i, k, worst = -1; float err = -1.0F; /* small enough */ for (k = 0; k < n; k++) { - float e = 0.0F; - for (i = 0; i < nc; i++) { - e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]); - } - if (e > err) { - err = e; - worst = k; - } + float e = 0.0F; + for (i = 0; i < nc; i++) { + e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]); + } + if (e > err) { + err = e; + worst = k; + } } return worst; } - static int -fxt1_variance (double variance[MAX_COMP], - byte input[N_TEXELS][MAX_COMP], int nc, int n) +fxt1_variance(double variance[MAX_COMP], + byte input[N_TEXELS][MAX_COMP], int nc, int n) { int i, k, best = 0; dword sx, sx2; @@ -111,29 +91,28 @@ fxt1_variance (double variance[MAX_COMP], double teenth = 1.0 / n; for (i = 0; i < nc; i++) { - sx = sx2 = 0; - for (k = 0; k < n; k++) { - int t = input[k][i]; - sx += t; - sx2 += t * t; - } - var = sx2 * teenth - sx * sx * teenth * teenth; - if (maxvar < var) { - maxvar = var; - best = i; - } - if (variance) { - variance[i] = var; - } + sx = sx2 = 0; + for (k = 0; k < n; k++) { + int t = input[k][i]; + sx += t; + sx2 += t * t; + } + var = sx2 * teenth - sx * sx * teenth * teenth; + if (maxvar < var) { + maxvar = var; + best = i; + } + if (variance) { + variance[i] = var; + } } return best; } - static int -fxt1_choose (float vec[][MAX_COMP], int nv, - byte input[N_TEXELS][MAX_COMP], int nc, int n) +fxt1_choose(float vec[][MAX_COMP], int nv, + byte input[N_TEXELS][MAX_COMP], int nc, int n) { #if 0 /* Choose colors from a grid. @@ -141,10 +120,10 @@ fxt1_choose (float vec[][MAX_COMP], int nv, int i, j; for (j = 0; j < nv; j++) { - int m = j * (n - 1) / (nv - 1); - for (i = 0; i < nc; i++) { - vec[j][i] = input[m][i]; - } + int m = j * (n - 1) / (nv - 1); + for (i = 0; i < nc; i++) { + vec[j][i] = input[m][i]; + } } #else /* Our solution here is to find the darkest and brightest colors in @@ -162,85 +141,85 @@ fxt1_choose (float vec[][MAX_COMP], int nv, int maxCol = 0; /* phoudoin: silent compiler! */ struct { - int flag; - dword key; - int freq; - int idx; + int flag; + dword key; + int freq; + int idx; } hist[N_TEXELS]; int lenh = 0; memset(hist, 0, sizeof(hist)); for (k = 0; k < n; k++) { - int l; - dword key = 0; - int sum = 0; - for (i = 0; i < nc; i++) { - key <<= 8; - key |= input[k][i]; + int l; + dword key = 0; + int sum = 0; + for (i = 0; i < nc; i++) { + key <<= 8; + key |= input[k][i]; #ifndef YUV - sum += input[k][i]; + sum += input[k][i]; #else /* RGB to YUV conversion according to CCIR 601 specs * Y = 0.299R+0.587G+0.114B * U = 0.713(R - Y) = 0.500R-0.419G-0.081B * V = 0.564(B - Y) = -0.169R-0.331G+0.500B */ - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif } - for (l = 0; l < n; l++) { - if (!hist[l].flag) { - /* alloc new slot */ - hist[l].flag = !0; - hist[l].key = key; - hist[l].freq = 1; - hist[l].idx = k; - lenh = l + 1; - break; - } else if (hist[l].key == key) { - hist[l].freq++; - break; - } - } - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } + for (l = 0; l < n; l++) { + if (!hist[l].flag) { + /* alloc new slot */ + hist[l].flag = !0; + hist[l].key = key; + hist[l].freq = 1; + hist[l].idx = k; + lenh = l + 1; + break; + } + else if (hist[l].key == key) { + hist[l].freq++; + break; + } + } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } } if (lenh <= nv) { - for (j = 0; j < lenh; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = (float)input[hist[j].idx][i]; - } - } - for (; j < nv; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = vec[0][i]; - } - } - return 0; + for (j = 0; j < lenh; j++) { + for (i = 0; i < nc; i++) { + vec[j][i] = (float)input[hist[j].idx][i]; + } + } + for (; j < nv; j++) { + for (i = 0; i < nc; i++) { + vec[j][i] = vec[0][i]; + } + } + return 0; } for (j = 0; j < nv; j++) { - for (i = 0; i < nc; i++) { - vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (float)(nv - 1); - } + for (i = 0; i < nc; i++) { + vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (float)(nv - 1); + } } #endif return !0; } - static int -fxt1_lloyd (float vec[][MAX_COMP], int nv, - byte input[N_TEXELS][MAX_COMP], int nc, int n) +fxt1_lloyd(float vec[][MAX_COMP], int nv, + byte input[N_TEXELS][MAX_COMP], int nc, int n) { /* Use the generalized lloyd's algorithm for VQ: * find 4 color vectors. @@ -270,77 +249,77 @@ fxt1_lloyd (float vec[][MAX_COMP], int nv, /* the quantizer */ for (rep = 0; rep < LL_N_REP; rep++) { - /* reset sums & counters */ - for (j = 0; j < nv; j++) { - for (i = 0; i < nc; i++) { - sum[j][i] = 0; - } - cnt[j] = 0; - } - error = 0; + /* reset sums & counters */ + for (j = 0; j < nv; j++) { + for (i = 0; i < nc; i++) { + sum[j][i] = 0; + } + cnt[j] = 0; + } + error = 0; - /* scan whole block */ - for (k = 0; k < n; k++) { + /* scan whole block */ + for (k = 0; k < n; k++) { #if 1 - int best = -1; - float err = 1e9; /* big enough */ - /* determine best vector */ - for (j = 0; j < nv; j++) { - float e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) + - (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) + - (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]); - if (nc == 4) { - e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]); - } - if (e < err) { - err = e; - best = j; - } - } + int best = -1; + float err = 1e9; /* big enough */ + /* determine best vector */ + for (j = 0; j < nv; j++) { + float e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) + + (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) + + (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]); + if (nc == 4) { + e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]); + } + if (e < err) { + err = e; + best = j; + } + } #else - int best = fxt1_bestcol(vec, nv, input[k], nc, &err); + int best = fxt1_bestcol(vec, nv, input[k], nc, &err); #endif - /* add in closest color */ - for (i = 0; i < nc; i++) { - sum[best][i] += input[k][i]; - } - /* mark this vector as used */ - cnt[best]++; - /* accumulate error */ - error += err; - } + /* add in closest color */ + for (i = 0; i < nc; i++) { + sum[best][i] += input[k][i]; + } + /* mark this vector as used */ + cnt[best]++; + /* accumulate error */ + error += err; + } - /* check RMS */ - if ((error < LL_RMS_E) || - ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) { - return !0; /* good match */ - } - lasterror = error; + /* check RMS */ + if ((error < LL_RMS_E) || + ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) { + return !0; /* good match */ + } + lasterror = error; - /* move each vector to the barycenter of its closest colors */ - for (j = 0; j < nv; j++) { - if (cnt[j]) { - float div = 1.0F / cnt[j]; - for (i = 0; i < nc; i++) { - vec[j][i] = div * sum[j][i]; - } - } else { - /* this vec has no samples or is identical with a previous vec */ - int worst = fxt1_worst(vec[j], input, nc, n); - for (i = 0; i < nc; i++) { - vec[j][i] = input[worst][i]; - } - } - } + /* move each vector to the barycenter of its closest colors */ + for (j = 0; j < nv; j++) { + if (cnt[j]) { + float div = 1.0F / cnt[j]; + for (i = 0; i < nc; i++) { + vec[j][i] = div * sum[j][i]; + } + } + else { + /* this vec has no samples or is identical with a previous vec */ + int worst = fxt1_worst(vec[j], input, nc, n); + for (i = 0; i < nc; i++) { + vec[j][i] = input[worst][i]; + } + } + } } return 0; /* could not converge fast enough */ } - static void -fxt1_quantize_CHROMA (dword *cc, - byte input[N_TEXELS][MAX_COMP]) +fxt1_quantize_CHROMA(dword *cc, + byte input[N_TEXELS][MAX_COMP]) { const int n_vect = 4; /* 4 base vectors to find */ const int n_comp = 3; /* 3 components: R, G, B */ @@ -350,39 +329,38 @@ fxt1_quantize_CHROMA (dword *cc, dword lohi, lolo; /* low quadword: hi dword, lo dword */ if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) { - fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS); + fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS); } Q_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */ for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - Q_SHL(hi, 5); - Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); - } + for (i = 0; i < n_comp; i++) { + /* add in colors */ + Q_SHL(hi, 5); + Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); + } } ((qword *)cc)[1] = hi; lohi = lolo = 0; /* right microtile */ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - lohi <<= 2; - lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp); + lohi <<= 2; + lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp); } /* left microtile */ for (; k >= 0; k--) { - lolo <<= 2; - lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp); + lolo <<= 2; + lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp); } cc[1] = lohi; cc[0] = lolo; } - static void -fxt1_quantize_ALPHA0 (dword *cc, - byte input[N_TEXELS][MAX_COMP], - byte reord[N_TEXELS][MAX_COMP], int n) +fxt1_quantize_ALPHA0(dword *cc, + byte input[N_TEXELS][MAX_COMP], + byte reord[N_TEXELS][MAX_COMP], int n) { const int n_vect = 3; /* 3 base vectors to find */ const int n_comp = 4; /* 4 components: R, G, B, A */ @@ -393,48 +371,47 @@ fxt1_quantize_ALPHA0 (dword *cc, /* the last vector indicates zero */ for (i = 0; i < n_comp; i++) { - vec[n_vect][i] = 0; + vec[n_vect][i] = 0; } /* the first n texels in reord are guaranteed to be non-zero */ if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) { - fxt1_lloyd(vec, n_vect, reord, n_comp, n); + fxt1_lloyd(vec, n_vect, reord, n_comp, n); } Q_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */ for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ - Q_SHL(hi, 5); - Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); + /* add in alphas */ + Q_SHL(hi, 5); + Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); } for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ - Q_SHL(hi, 5); - Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); - } + for (i = 0; i < n_comp - 1; i++) { + /* add in colors */ + Q_SHL(hi, 5); + Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); + } } ((qword *)cc)[1] = hi; lohi = lolo = 0; /* right microtile */ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - lohi <<= 2; - lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); + lohi <<= 2; + lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); } /* left microtile */ for (; k >= 0; k--) { - lolo <<= 2; - lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); + lolo <<= 2; + lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp); } cc[1] = lohi; cc[0] = lolo; } - static void -fxt1_quantize_ALPHA1 (dword *cc, - byte input[N_TEXELS][MAX_COMP]) +fxt1_quantize_ALPHA1(dword *cc, + byte input[N_TEXELS][MAX_COMP]) { const int n_vect = 3; /* highest vector number in each microtile */ const int n_comp = 4; /* 4 components: R, G, B, A */ @@ -461,23 +438,23 @@ fxt1_quantize_ALPHA1 (dword *cc, #endif maxSum = -1; /* small enough */ for (k = 0; k < N_TEXELS / 2; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - sumL += sum; + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + sumL += sum; } #ifndef YUV minSum = 2000; /* big enough */ @@ -486,118 +463,117 @@ fxt1_quantize_ALPHA1 (dword *cc, #endif maxSum = -1; /* small enough */ for (; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - sumR += sum; + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + sumR += sum; } /* choose the common vector (yuck!) */ { - int j1, j2; - int v1 = 0, v2 = 0; - float err = 1e9; /* big enough */ - float tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ - for (i = 0; i < n_comp; i++) { - tv[0][i] = input[minColL][i]; - tv[1][i] = input[maxColL][i]; - tv[2][i] = input[minColR][i]; - tv[3][i] = input[maxColR][i]; - } - for (j1 = 0; j1 < 2; j1++) { - for (j2 = 2; j2 < 4; j2++) { - float e = 0.0F; - for (i = 0; i < n_comp; i++) { - e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]); - } - if (e < err) { - err = e; - v1 = j1; - v2 = j2; - } - } - } - for (i = 0; i < n_comp; i++) { - vec[0][i] = tv[1 - v1][i]; - vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR); - vec[2][i] = tv[5 - v2][i]; - } + int j1, j2; + int v1 = 0, v2 = 0; + float err = 1e9; /* big enough */ + float tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */ + for (i = 0; i < n_comp; i++) { + tv[0][i] = input[minColL][i]; + tv[1][i] = input[maxColL][i]; + tv[2][i] = input[minColR][i]; + tv[3][i] = input[maxColR][i]; + } + for (j1 = 0; j1 < 2; j1++) { + for (j2 = 2; j2 < 4; j2++) { + float e = 0.0F; + for (i = 0; i < n_comp; i++) { + e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]); + } + if (e < err) { + err = e; + v1 = j1; + v2 = j2; + } + } + } + for (i = 0; i < n_comp; i++) { + vec[0][i] = tv[1 - v1][i]; + vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR); + vec[2][i] = tv[5 - v2][i]; + } } /* left microtile */ cc[0] = 0; if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } - cc[0] = lolo; + cc[0] = lolo; } /* right microtile */ cc[1] = 0; if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]); + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]); - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } - cc[1] = lohi; + cc[1] = lohi; } Q_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */ for (j = n_vect - 1; j >= 0; j--) { - /* add in alphas */ - Q_SHL(hi, 5); - Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); + /* add in alphas */ + Q_SHL(hi, 5); + Q_OR32(hi, (dword)(vec[j][ACOMP] / 8.0F)); } for (j = n_vect - 1; j >= 0; j--) { - for (i = 0; i < n_comp - 1; i++) { - /* add in colors */ - Q_SHL(hi, 5); - Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); - } + for (i = 0; i < n_comp - 1; i++) { + /* add in colors */ + Q_SHL(hi, 5); + Q_OR32(hi, (dword)(vec[j][i] / 8.0F)); + } } ((qword *)cc)[1] = hi; } - static void -fxt1_quantize_HI (dword *cc, - byte input[N_TEXELS][MAX_COMP], - byte reord[N_TEXELS][MAX_COMP], int n) +fxt1_quantize_HI(dword *cc, + byte input[N_TEXELS][MAX_COMP], + byte reord[N_TEXELS][MAX_COMP], int n) { const int n_vect = 6; /* highest vector number */ const int n_comp = 3; /* 3 components: R, G, B */ @@ -620,67 +596,67 @@ fxt1_quantize_HI (dword *cc, * There are probably better algorithms to use (histogram-based). */ for (k = 0; k < n; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += reord[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += reord[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minCol = k; - } - if (maxSum < sum) { - maxSum = sum; - maxCol = k; - } + if (minSum > sum) { + minSum = sum; + minCol = k; + } + if (maxSum < sum) { + maxSum = sum; + maxCol = k; + } } hihi = 0; /* cc-hi = "00" */ for (i = 0; i < n_comp; i++) { - /* add in colors */ - hihi <<= 5; - hihi |= reord[maxCol][i] >> 3; + /* add in colors */ + hihi <<= 5; + hihi |= reord[maxCol][i] >> 3; } for (i = 0; i < n_comp; i++) { - /* add in colors */ - hihi <<= 5; - hihi |= reord[minCol][i] >> 3; + /* add in colors */ + hihi <<= 5; + hihi |= reord[minCol][i] >> 3; } cc[3] = hihi; cc[0] = cc[1] = cc[2] = 0; /* compute interpolation vector */ if (minCol != maxCol) { - MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]); + MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]); } /* add in texels */ for (k = N_TEXELS - 1; k >= 0; k--) { - int t = k * 3; - dword *kk = (dword *)((byte *)cc + t / 8); - int texel = n_vect + 1; /* transparent black */ + int t = k * 3; + dword *kk = (dword *)((byte *)cc + t / 8); + int texel = n_vect + 1; /* transparent black */ - if (!ISTBLACK(input[k])) { - if (minCol != maxCol) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - kk[0] |= texel << (t & 7); - } - } else { - /* add in texel */ - kk[0] |= texel << (t & 7); - } + if (!ISTBLACK(input[k])) { + if (minCol != maxCol) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + kk[0] |= texel << (t & 7); + } + } + else { + /* add in texel */ + kk[0] |= texel << (t & 7); + } } } - static void -fxt1_quantize_MIXED1 (dword *cc, - byte input[N_TEXELS][MAX_COMP]) +fxt1_quantize_MIXED1(dword *cc, + byte input[N_TEXELS][MAX_COMP]) { const int n_vect = 2; /* highest vector number in each microtile */ const int n_comp = 3; /* 3 components: R, G, B */ @@ -706,24 +682,24 @@ fxt1_quantize_MIXED1 (dword *cc, #endif maxSum = -1; /* small enough */ for (k = 0; k < N_TEXELS / 2; k++) { - if (!ISTBLACK(input[k])) { - int sum = 0; + if (!ISTBLACK(input[k])) { + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } - } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } + } } #ifndef YUV minSum = 2000; /* big enough */ @@ -732,109 +708,110 @@ fxt1_quantize_MIXED1 (dword *cc, #endif maxSum = -1; /* small enough */ for (; k < N_TEXELS; k++) { - if (!ISTBLACK(input[k])) { - int sum = 0; + if (!ISTBLACK(input[k])) { + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } - } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } + } } /* left microtile */ if (maxColL == -1) { - /* all transparent black */ - cc[0] = 0xFFFFFFFFUL; - for (i = 0; i < n_comp; i++) { - vec[0][i] = 0; - vec[1][i] = 0; - } - } else { - cc[0] = 0; - for (i = 0; i < n_comp; i++) { - vec[0][i] = input[minColL][i]; - vec[1][i] = input[maxColL][i]; - } - if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + /* all transparent black */ + cc[0] = 0xFFFFFFFFUL; + for (i = 0; i < n_comp; i++) { + vec[0][i] = 0; + vec[1][i] = 0; + } + } + else { + cc[0] = 0; + for (i = 0; i < n_comp; i++) { + vec[0][i] = input[minColL][i]; + vec[1][i] = input[maxColL][i]; + } + if (minColL != maxColL) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - int texel = n_vect + 1; /* transparent black */ - if (!ISTBLACK(input[k])) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - } - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } - cc[0] = lolo; - } + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + int texel = n_vect + 1; /* transparent black */ + if (!ISTBLACK(input[k])) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + } + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } + cc[0] = lolo; + } } /* right microtile */ if (maxColR == -1) { - /* all transparent black */ - cc[1] = 0xFFFFFFFFUL; - for (i = 0; i < n_comp; i++) { - vec[2][i] = 0; - vec[3][i] = 0; - } - } else { - cc[1] = 0; - for (i = 0; i < n_comp; i++) { - vec[2][i] = input[minColR][i]; - vec[3][i] = input[maxColR][i]; - } - if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); + /* all transparent black */ + cc[1] = 0xFFFFFFFFUL; + for (i = 0; i < n_comp; i++) { + vec[2][i] = 0; + vec[3][i] = 0; + } + } + else { + cc[1] = 0; + for (i = 0; i < n_comp; i++) { + vec[2][i] = input[minColR][i]; + vec[3][i] = input[maxColR][i]; + } + if (minColR != maxColR) { + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - int texel = n_vect + 1; /* transparent black */ - if (!ISTBLACK(input[k])) { - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - } - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } - cc[1] = lohi; - } + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + int texel = n_vect + 1; /* transparent black */ + if (!ISTBLACK(input[k])) { + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + } + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } + cc[1] = lohi; + } } Q_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ for (j = 2 * 2 - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - Q_SHL(hi, 5); - Q_OR32(hi, vec[j][i] >> 3); - } + for (i = 0; i < n_comp; i++) { + /* add in colors */ + Q_SHL(hi, 5); + Q_OR32(hi, vec[j][i] >> 3); + } } ((qword *)cc)[1] = hi; } - static void -fxt1_quantize_MIXED0 (dword *cc, - byte input[N_TEXELS][MAX_COMP]) +fxt1_quantize_MIXED0(dword *cc, + byte input[N_TEXELS][MAX_COMP]) { const int n_vect = 3; /* highest vector number in each microtile */ const int n_comp = 3; /* 3 components: R, G, B */ @@ -861,42 +838,42 @@ fxt1_quantize_MIXED0 (dword *cc, #endif maxSum = -1; /* small enough */ for (k = 0; k < N_TEXELS / 2; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColL = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColL = k; - } + if (minSum > sum) { + minSum = sum; + minColL = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColL = k; + } } minSum = 2000; /* big enough */ maxSum = -1; /* small enough */ for (; k < N_TEXELS; k++) { - int sum = 0; + int sum = 0; #ifndef YUV - for (i = 0; i < n_comp; i++) { - sum += input[k][i]; - } + for (i = 0; i < n_comp; i++) { + sum += input[k][i]; + } #else - sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; + sum = 299 * input[k][RCOMP] + 587 * input[k][GCOMP] + 114 * input[k][BCOMP]; #endif - if (minSum > sum) { - minSum = sum; - minColR = k; - } - if (maxSum < sum) { - maxSum = sum; - maxColR = k; - } + if (minSum > sum) { + minSum = sum; + minColR = k; + } + if (maxSum < sum) { + maxSum = sum; + maxColR = k; + } } #else int minVal; @@ -910,111 +887,110 @@ fxt1_quantize_MIXED0 (dword *cc, minVal = 2000; /* big enough */ maxVal = -1; /* small enough */ for (k = 0; k < N_TEXELS / 2; k++) { - int t = input[k][maxVarL]; - if (minVal > t) { - minVal = t; - minColL = k; - } - if (maxVal < t) { - maxVal = t; - maxColL = k; - } + int t = input[k][maxVarL]; + if (minVal > t) { + minVal = t; + minColL = k; + } + if (maxVal < t) { + maxVal = t; + maxColL = k; + } } minVal = 2000; /* big enough */ maxVal = -1; /* small enough */ for (; k < N_TEXELS; k++) { - int t = input[k][maxVarR]; - if (minVal > t) { - minVal = t; - minColR = k; - } - if (maxVal < t) { - maxVal = t; - maxColR = k; - } + int t = input[k][maxVarR]; + if (minVal > t) { + minVal = t; + minColR = k; + } + if (maxVal < t) { + maxVal = t; + maxColR = k; + } } #endif /* left microtile */ cc[0] = 0; for (i = 0; i < n_comp; i++) { - vec[0][i] = input[minColL][i]; - vec[1][i] = input[maxColL][i]; + vec[0][i] = input[minColL][i]; + vec[1][i] = input[maxColL][i]; } if (minColL != maxColL) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]); - /* add in texels */ - lolo = 0; - for (k = N_TEXELS / 2 - 1; k >= 0; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lolo <<= 2; - lolo |= texel; - } + /* add in texels */ + lolo = 0; + for (k = N_TEXELS / 2 - 1; k >= 0; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lolo <<= 2; + lolo |= texel; + } - /* funky encoding for LSB of green */ - if ((int)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) { - for (i = 0; i < n_comp; i++) { - vec[1][i] = input[minColL][i]; - vec[0][i] = input[maxColL][i]; - } - lolo = ~lolo; - } + /* funky encoding for LSB of green */ + if ((int)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) { + for (i = 0; i < n_comp; i++) { + vec[1][i] = input[minColL][i]; + vec[0][i] = input[maxColL][i]; + } + lolo = ~lolo; + } - cc[0] = lolo; + cc[0] = lolo; } /* right microtile */ cc[1] = 0; for (i = 0; i < n_comp; i++) { - vec[2][i] = input[minColR][i]; - vec[3][i] = input[maxColR][i]; + vec[2][i] = input[minColR][i]; + vec[3][i] = input[maxColR][i]; } if (minColR != maxColR) { - /* compute interpolation vector */ - MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); + /* compute interpolation vector */ + MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]); - /* add in texels */ - lohi = 0; - for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { - int texel; - /* interpolate color */ - CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); - /* add in texel */ - lohi <<= 2; - lohi |= texel; - } + /* add in texels */ + lohi = 0; + for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) { + int texel; + /* interpolate color */ + CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]); + /* add in texel */ + lohi <<= 2; + lohi |= texel; + } - /* funky encoding for LSB of green */ - if ((int)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) { - for (i = 0; i < n_comp; i++) { - vec[3][i] = input[minColR][i]; - vec[2][i] = input[maxColR][i]; - } - lohi = ~lohi; - } + /* funky encoding for LSB of green */ + if ((int)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) { + for (i = 0; i < n_comp; i++) { + vec[3][i] = input[minColR][i]; + vec[2][i] = input[maxColR][i]; + } + lohi = ~lohi; + } - cc[1] = lohi; + cc[1] = lohi; } Q_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */ for (j = 2 * 2 - 1; j >= 0; j--) { - for (i = 0; i < n_comp; i++) { - /* add in colors */ - Q_SHL(hi, 5); - Q_OR32(hi, vec[j][i] >> 3); - } + for (i = 0; i < n_comp; i++) { + /* add in colors */ + Q_SHL(hi, 5); + Q_OR32(hi, vec[j][i] >> 3); + } } ((qword *)cc)[1] = hi; } - static void -fxt1_quantize (dword *cc, const byte *lines[], int comps) +fxt1_quantize(dword *cc, const byte *lines[], int comps) { int trualpha; byte reord[N_TEXELS][MAX_COMP]; @@ -1026,39 +1002,39 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps) int k, l; if (comps == 3) { - /* make the whole block opaque */ - memset(input, -1, sizeof(input)); + /* make the whole block opaque */ + memset(input, -1, sizeof(input)); } /* 8 texels each line */ #ifndef ARGB for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4][i] = *lines[l]++; - } - } - for (; k < 8; k++) { - for (i = 0; i < comps; i++) { - input[k + l * 4 + 12][i] = *lines[l]++; - } - } + for (k = 0; k < 4; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4][i] = *lines[l]++; + } + } + for (; k < 8; k++) { + for (i = 0; i < comps; i++) { + input[k + l * 4 + 12][i] = *lines[l]++; + } + } } #else /* H.Morii - support for ARGB inputs */ for (l = 0; l < 4; l++) { - for (k = 0; k < 4; k++) { - input[k + l * 4][2] = *lines[l]++; - input[k + l * 4][1] = *lines[l]++; - input[k + l * 4][0] = *lines[l]++; - if (comps == 4) input[k + l * 4][3] = *lines[l]++; - } - for (; k < 8; k++) { - input[k + l * 4 + 12][2] = *lines[l]++; - input[k + l * 4 + 12][1] = *lines[l]++; - input[k + l * 4 + 12][0] = *lines[l]++; - if (comps == 4) input[k + l * 4 + 12][3] = *lines[l]++; - } + for (k = 0; k < 4; k++) { + input[k + l * 4][2] = *lines[l]++; + input[k + l * 4][1] = *lines[l]++; + input[k + l * 4][0] = *lines[l]++; + if (comps == 4) input[k + l * 4][3] = *lines[l]++; + } + for (; k < 8; k++) { + input[k + l * 4 + 12][2] = *lines[l]++; + input[k + l * 4 + 12][1] = *lines[l]++; + input[k + l * 4 + 12][0] = *lines[l]++; + if (comps == 4) input[k + l * 4 + 12][3] = *lines[l]++; + } } #endif @@ -1069,52 +1045,58 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps) * 14, 15, 16, 17, 1c, 1d, 1e, 1f */ - /* [dBorca] - * stupidity flows forth from this - */ + /* [dBorca] + * stupidity flows forth from this + */ l = N_TEXELS; trualpha = 0; if (comps == 4) { - /* skip all transparent black texels */ - l = 0; - for (k = 0; k < N_TEXELS; k++) { - /* test all components against 0 */ - if (!ISTBLACK(input[k])) { - /* texel is not transparent black */ - COPY_4UBV(reord[l], input[k]); - if (reord[l][ACOMP] < (255 - ALPHA_TS)) { - /* non-opaque texel */ - trualpha = !0; - } - l++; - } - } + /* skip all transparent black texels */ + l = 0; + for (k = 0; k < N_TEXELS; k++) { + /* test all components against 0 */ + if (!ISTBLACK(input[k])) { + /* texel is not transparent black */ + COPY_4UBV(reord[l], input[k]); + if (reord[l][ACOMP] < (255 - ALPHA_TS)) { + /* non-opaque texel */ + trualpha = !0; + } + l++; + } + } } #if 0 if (trualpha) { - fxt1_quantize_ALPHA0(cc, input, reord, l); - } else if (l == 0) { - cc[0] = cc[1] = cc[2] = -1; - cc[3] = 0; - } else if (l < N_TEXELS) { - fxt1_quantize_HI(cc, input, reord, l); - } else { - fxt1_quantize_CHROMA(cc, input); + fxt1_quantize_ALPHA0(cc, input, reord, l); + } + else if (l == 0) { + cc[0] = cc[1] = cc[2] = -1; + cc[3] = 0; + } + else if (l < N_TEXELS) { + fxt1_quantize_HI(cc, input, reord, l); + } + else { + fxt1_quantize_CHROMA(cc, input); } (void)fxt1_quantize_ALPHA1; (void)fxt1_quantize_MIXED1; (void)fxt1_quantize_MIXED0; #else if (trualpha) { - fxt1_quantize_ALPHA1(cc, input); - } else if (l == 0) { - cc[0] = cc[1] = cc[2] = 0xFFFFFFFFUL; - cc[3] = 0; - } else if (l < N_TEXELS) { - fxt1_quantize_MIXED1(cc, input); - } else { - fxt1_quantize_MIXED0(cc, input); + fxt1_quantize_ALPHA1(cc, input); + } + else if (l == 0) { + cc[0] = cc[1] = cc[2] = 0xFFFFFFFFUL; + cc[3] = 0; + } + else if (l < N_TEXELS) { + fxt1_quantize_MIXED1(cc, input); + } + else { + fxt1_quantize_MIXED0(cc, input); } (void)fxt1_quantize_ALPHA0; (void)fxt1_quantize_HI; @@ -1122,11 +1104,10 @@ fxt1_quantize (dword *cc, const byte *lines[], int comps) #endif } - TAPI int TAPIENTRY -fxt1_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride) +fxt1_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride) { int x, y; const byte *data; @@ -1135,44 +1116,43 @@ fxt1_encode (int width, int height, int comps, /* Replicate image if width is not M8 or height is not M4 */ if ((width & 7) | (height & 3)) { - int newWidth = (width + 7) & ~7; - int newHeight = (height + 3) & ~3; - newSource = malloc(comps * newWidth * newHeight * sizeof(byte *)); - _mesa_upscale_teximage2d(width, height, newWidth, newHeight, - comps, (const byte *)source, - srcRowStride, (byte *)newSource); - source = newSource; - width = newWidth; - height = newHeight; - srcRowStride = comps * newWidth; + int newWidth = (width + 7) & ~7; + int newHeight = (height + 3) & ~3; + newSource = malloc(comps * newWidth * newHeight * sizeof(byte *)); + _mesa_upscale_teximage2d(width, height, newWidth, newHeight, + comps, (const byte *)source, + srcRowStride, (byte *)newSource); + source = newSource; + width = newWidth; + height = newHeight; + srcRowStride = comps * newWidth; } data = (const byte *)source; destRowStride = (destRowStride - width * 2) / 4; for (y = 0; y < height; y += 4) { - unsigned int offs = 0 + (y + 0) * srcRowStride; - for (x = 0; x < width; x += 8) { - const byte *lines[4]; - lines[0] = &data[offs]; - lines[1] = lines[0] + srcRowStride; - lines[2] = lines[1] + srcRowStride; - lines[3] = lines[2] + srcRowStride; - offs += 8 * comps; - fxt1_quantize(encoded, lines, comps); - /* 128 bits per 8x4 block */ - encoded += 4; - } - encoded += destRowStride; + unsigned int offs = 0 + (y + 0) * srcRowStride; + for (x = 0; x < width; x += 8) { + const byte *lines[4]; + lines[0] = &data[offs]; + lines[1] = lines[0] + srcRowStride; + lines[2] = lines[1] + srcRowStride; + lines[3] = lines[2] + srcRowStride; + offs += 8 * comps; + fxt1_quantize(encoded, lines, comps); + /* 128 bits per 8x4 block */ + encoded += 4; + } + encoded += destRowStride; } if (newSource != NULL) { - free(newSource); + free(newSource); } return 0; } - /***************************************************************************\ * FXT1 decoder * @@ -1180,7 +1160,6 @@ fxt1_encode (int width, int height, int comps, * specification and serves as a concept for the encoder. \***************************************************************************/ - /* lookup table for scaling 5 bit colors up to 8 bits */ static const byte _rgb_scale_5[] = { 0, 8, 16, 25, 33, 41, 49, 58, @@ -1201,16 +1180,14 @@ static const byte _rgb_scale_6[] = { 227, 231, 235, 239, 243, 247, 251, 255 }; - #define CC_SEL(cc, which) (((dword *)(cc))[(which) / 32] >> ((which) & 31)) #define UP5(c) _rgb_scale_5[(c) & 31] #define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)] #define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n) #define ZERO_4UBV(v) *((dword *)(v)) = 0 - static void -fxt1_decode_1HI (const byte *code, int t, byte *rgba) +fxt1_decode_1HI(const byte *code, int t, byte *rgba) { const dword *cc; @@ -1219,37 +1196,39 @@ fxt1_decode_1HI (const byte *code, int t, byte *rgba) t = (cc[0] >> (t & 7)) & 7; if (t == 7) { - ZERO_4UBV(rgba); - } else { - cc = (const dword *)(code + 12); - if (t == 0) { - rgba[BCOMP] = UP5(CC_SEL(cc, 0)); - rgba[GCOMP] = UP5(CC_SEL(cc, 5)); - rgba[RCOMP] = UP5(CC_SEL(cc, 10)); - } else if (t == 6) { - rgba[BCOMP] = UP5(CC_SEL(cc, 15)); - rgba[GCOMP] = UP5(CC_SEL(cc, 20)); - rgba[RCOMP] = UP5(CC_SEL(cc, 25)); - } else { - rgba[BCOMP] = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15))); - rgba[GCOMP] = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20))); - rgba[RCOMP] = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25))); - } - rgba[ACOMP] = 255; + ZERO_4UBV(rgba); + } + else { + cc = (const dword *)(code + 12); + if (t == 0) { + rgba[BCOMP] = UP5(CC_SEL(cc, 0)); + rgba[GCOMP] = UP5(CC_SEL(cc, 5)); + rgba[RCOMP] = UP5(CC_SEL(cc, 10)); + } + else if (t == 6) { + rgba[BCOMP] = UP5(CC_SEL(cc, 15)); + rgba[GCOMP] = UP5(CC_SEL(cc, 20)); + rgba[RCOMP] = UP5(CC_SEL(cc, 25)); + } + else { + rgba[BCOMP] = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15))); + rgba[GCOMP] = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20))); + rgba[RCOMP] = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25))); + } + rgba[ACOMP] = 255; } } - static void -fxt1_decode_1CHROMA (const byte *code, int t, byte *rgba) +fxt1_decode_1CHROMA(const byte *code, int t, byte *rgba) { const dword *cc; dword kk; cc = (const dword *)code; if (t & 16) { - cc++; - t &= 15; + cc++; + t &= 15; } t = (cc[0] >> (t * 2)) & 3; @@ -1262,9 +1241,8 @@ fxt1_decode_1CHROMA (const byte *code, int t, byte *rgba) rgba[ACOMP] = 255; } - static void -fxt1_decode_1MIXED (const byte *code, int t, byte *rgba) +fxt1_decode_1MIXED(const byte *code, int t, byte *rgba) { const dword *cc; int col[2][3]; @@ -1272,166 +1250,176 @@ fxt1_decode_1MIXED (const byte *code, int t, byte *rgba) cc = (const dword *)code; if (t & 16) { - t &= 15; - t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ - col[0][BCOMP] = (*(const dword *)(code + 11)) >> 6; - col[0][GCOMP] = CC_SEL(cc, 99); - col[0][RCOMP] = CC_SEL(cc, 104); - /* col 3 */ - col[1][BCOMP] = CC_SEL(cc, 109); - col[1][GCOMP] = CC_SEL(cc, 114); - col[1][RCOMP] = CC_SEL(cc, 119); - glsb = CC_SEL(cc, 126); - selb = CC_SEL(cc, 33); - } else { - t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ - col[0][BCOMP] = CC_SEL(cc, 64); - col[0][GCOMP] = CC_SEL(cc, 69); - col[0][RCOMP] = CC_SEL(cc, 74); - /* col 1 */ - col[1][BCOMP] = CC_SEL(cc, 79); - col[1][GCOMP] = CC_SEL(cc, 84); - col[1][RCOMP] = CC_SEL(cc, 89); - glsb = CC_SEL(cc, 125); - selb = CC_SEL(cc, 1); + t &= 15; + t = (cc[1] >> (t * 2)) & 3; + /* col 2 */ + col[0][BCOMP] = (*(const dword *)(code + 11)) >> 6; + col[0][GCOMP] = CC_SEL(cc, 99); + col[0][RCOMP] = CC_SEL(cc, 104); + /* col 3 */ + col[1][BCOMP] = CC_SEL(cc, 109); + col[1][GCOMP] = CC_SEL(cc, 114); + col[1][RCOMP] = CC_SEL(cc, 119); + glsb = CC_SEL(cc, 126); + selb = CC_SEL(cc, 33); + } + else { + t = (cc[0] >> (t * 2)) & 3; + /* col 0 */ + col[0][BCOMP] = CC_SEL(cc, 64); + col[0][GCOMP] = CC_SEL(cc, 69); + col[0][RCOMP] = CC_SEL(cc, 74); + /* col 1 */ + col[1][BCOMP] = CC_SEL(cc, 79); + col[1][GCOMP] = CC_SEL(cc, 84); + col[1][RCOMP] = CC_SEL(cc, 89); + glsb = CC_SEL(cc, 125); + selb = CC_SEL(cc, 1); } if (CC_SEL(cc, 124) & 1) { - /* alpha[0] == 1 */ + /* alpha[0] == 1 */ - if (t == 3) { - ZERO_4UBV(rgba); - } else { - if (t == 0) { - rgba[BCOMP] = UP5(col[0][BCOMP]); - rgba[GCOMP] = UP5(col[0][GCOMP]); - rgba[RCOMP] = UP5(col[0][RCOMP]); - } else if (t == 2) { - rgba[BCOMP] = UP5(col[1][BCOMP]); - rgba[GCOMP] = UP6(col[1][GCOMP], glsb); - rgba[RCOMP] = UP5(col[1][RCOMP]); - } else { - rgba[BCOMP] = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2; - rgba[GCOMP] = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2; - rgba[RCOMP] = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2; - } - rgba[ACOMP] = 255; - } - } else { - /* alpha[0] == 0 */ + if (t == 3) { + ZERO_4UBV(rgba); + } + else { + if (t == 0) { + rgba[BCOMP] = UP5(col[0][BCOMP]); + rgba[GCOMP] = UP5(col[0][GCOMP]); + rgba[RCOMP] = UP5(col[0][RCOMP]); + } + else if (t == 2) { + rgba[BCOMP] = UP5(col[1][BCOMP]); + rgba[GCOMP] = UP6(col[1][GCOMP], glsb); + rgba[RCOMP] = UP5(col[1][RCOMP]); + } + else { + rgba[BCOMP] = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2; + rgba[GCOMP] = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2; + rgba[RCOMP] = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2; + } + rgba[ACOMP] = 255; + } + } + else { + /* alpha[0] == 0 */ - if (t == 0) { - rgba[BCOMP] = UP5(col[0][BCOMP]); - rgba[GCOMP] = UP6(col[0][GCOMP], glsb ^ selb); - rgba[RCOMP] = UP5(col[0][RCOMP]); - } else if (t == 3) { - rgba[BCOMP] = UP5(col[1][BCOMP]); - rgba[GCOMP] = UP6(col[1][GCOMP], glsb); - rgba[RCOMP] = UP5(col[1][RCOMP]); - } else { - rgba[BCOMP] = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP])); - rgba[GCOMP] = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb), - UP6(col[1][GCOMP], glsb)); - rgba[RCOMP] = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP])); - } - rgba[ACOMP] = 255; + if (t == 0) { + rgba[BCOMP] = UP5(col[0][BCOMP]); + rgba[GCOMP] = UP6(col[0][GCOMP], glsb ^ selb); + rgba[RCOMP] = UP5(col[0][RCOMP]); + } + else if (t == 3) { + rgba[BCOMP] = UP5(col[1][BCOMP]); + rgba[GCOMP] = UP6(col[1][GCOMP], glsb); + rgba[RCOMP] = UP5(col[1][RCOMP]); + } + else { + rgba[BCOMP] = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP])); + rgba[GCOMP] = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb), + UP6(col[1][GCOMP], glsb)); + rgba[RCOMP] = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP])); + } + rgba[ACOMP] = 255; } } - static void -fxt1_decode_1ALPHA (const byte *code, int t, byte *rgba) +fxt1_decode_1ALPHA(const byte *code, int t, byte *rgba) { const dword *cc; cc = (const dword *)code; if (CC_SEL(cc, 124) & 1) { - /* lerp == 1 */ - int col0[4]; + /* lerp == 1 */ + int col0[4]; - if (t & 16) { - t &= 15; - t = (cc[1] >> (t * 2)) & 3; - /* col 2 */ - col0[BCOMP] = (*(const dword *)(code + 11)) >> 6; - col0[GCOMP] = CC_SEL(cc, 99); - col0[RCOMP] = CC_SEL(cc, 104); - col0[ACOMP] = CC_SEL(cc, 119); - } else { - t = (cc[0] >> (t * 2)) & 3; - /* col 0 */ - col0[BCOMP] = CC_SEL(cc, 64); - col0[GCOMP] = CC_SEL(cc, 69); - col0[RCOMP] = CC_SEL(cc, 74); - col0[ACOMP] = CC_SEL(cc, 109); - } + if (t & 16) { + t &= 15; + t = (cc[1] >> (t * 2)) & 3; + /* col 2 */ + col0[BCOMP] = (*(const dword *)(code + 11)) >> 6; + col0[GCOMP] = CC_SEL(cc, 99); + col0[RCOMP] = CC_SEL(cc, 104); + col0[ACOMP] = CC_SEL(cc, 119); + } + else { + t = (cc[0] >> (t * 2)) & 3; + /* col 0 */ + col0[BCOMP] = CC_SEL(cc, 64); + col0[GCOMP] = CC_SEL(cc, 69); + col0[RCOMP] = CC_SEL(cc, 74); + col0[ACOMP] = CC_SEL(cc, 109); + } - if (t == 0) { - rgba[BCOMP] = UP5(col0[BCOMP]); - rgba[GCOMP] = UP5(col0[GCOMP]); - rgba[RCOMP] = UP5(col0[RCOMP]); - rgba[ACOMP] = UP5(col0[ACOMP]); - } else if (t == 3) { - rgba[BCOMP] = UP5(CC_SEL(cc, 79)); - rgba[GCOMP] = UP5(CC_SEL(cc, 84)); - rgba[RCOMP] = UP5(CC_SEL(cc, 89)); - rgba[ACOMP] = UP5(CC_SEL(cc, 114)); - } else { - rgba[BCOMP] = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79))); - rgba[GCOMP] = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84))); - rgba[RCOMP] = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89))); - rgba[ACOMP] = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114))); - } - } else { - /* lerp == 0 */ + if (t == 0) { + rgba[BCOMP] = UP5(col0[BCOMP]); + rgba[GCOMP] = UP5(col0[GCOMP]); + rgba[RCOMP] = UP5(col0[RCOMP]); + rgba[ACOMP] = UP5(col0[ACOMP]); + } + else if (t == 3) { + rgba[BCOMP] = UP5(CC_SEL(cc, 79)); + rgba[GCOMP] = UP5(CC_SEL(cc, 84)); + rgba[RCOMP] = UP5(CC_SEL(cc, 89)); + rgba[ACOMP] = UP5(CC_SEL(cc, 114)); + } + else { + rgba[BCOMP] = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79))); + rgba[GCOMP] = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84))); + rgba[RCOMP] = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89))); + rgba[ACOMP] = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114))); + } + } + else { + /* lerp == 0 */ - if (t & 16) { - cc++; - t &= 15; - } - t = (cc[0] >> (t * 2)) & 3; + if (t & 16) { + cc++; + t &= 15; + } + t = (cc[0] >> (t * 2)) & 3; - if (t == 3) { - ZERO_4UBV(rgba); - } else { - dword kk; - cc = (const dword *)code; - rgba[ACOMP] = UP5(cc[3] >> (t * 5 + 13)); - t *= 15; - cc = (const dword *)(code + 8 + t / 8); - kk = cc[0] >> (t & 7); - rgba[BCOMP] = UP5(kk); - rgba[GCOMP] = UP5(kk >> 5); - rgba[RCOMP] = UP5(kk >> 10); - } + if (t == 3) { + ZERO_4UBV(rgba); + } + else { + dword kk; + cc = (const dword *)code; + rgba[ACOMP] = UP5(cc[3] >> (t * 5 + 13)); + t *= 15; + cc = (const dword *)(code + 8 + t / 8); + kk = cc[0] >> (t & 7); + rgba[BCOMP] = UP5(kk); + rgba[GCOMP] = UP5(kk >> 5); + rgba[RCOMP] = UP5(kk >> 10); + } } } - TAPI void TAPIENTRY -fxt1_decode_1 (const void *texture, int stride, - int i, int j, byte *rgba) +fxt1_decode_1(const void *texture, int stride, + int i, int j, byte *rgba) { - static void (*decode_1[]) (const byte *, int, byte *) = { - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1HI, /* cc-high = "00?" */ - fxt1_decode_1CHROMA, /* cc-chroma = "010" */ - fxt1_decode_1ALPHA, /* alpha = "011" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED, /* mixed = "1??" */ - fxt1_decode_1MIXED /* mixed = "1??" */ + static void(*decode_1[]) (const byte *, int, byte *) = { + fxt1_decode_1HI, /* cc-high = "00?" */ + fxt1_decode_1HI, /* cc-high = "00?" */ + fxt1_decode_1CHROMA, /* cc-chroma = "010" */ + fxt1_decode_1ALPHA, /* alpha = "011" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED, /* mixed = "1??" */ + fxt1_decode_1MIXED /* mixed = "1??" */ }; const byte *code = (const byte *)texture + - ((j / 4) * (stride / 8) + (i / 8)) * 16; + ((j / 4) * (stride / 8) + (i / 8)) * 16; int mode = CC_SEL(code, 125); int t = i & 7; if (t & 4) { - t += 12; + t += 12; } t += (j & 3) * 4; @@ -1439,21 +1427,21 @@ fxt1_decode_1 (const void *texture, int stride, #if VERBOSE { - extern int cc_chroma; - extern int cc_alpha; - extern int cc_high; - extern int cc_mixed; - static int *cctype[] = { - &cc_high, - &cc_high, - &cc_chroma, - &cc_alpha, - &cc_mixed, - &cc_mixed, - &cc_mixed, - &cc_mixed - }; - (*cctype[mode])++; + extern int cc_chroma; + extern int cc_alpha; + extern int cc_high; + extern int cc_mixed; + static int *cctype[] = { + &cc_high, + &cc_high, + &cc_chroma, + &cc_alpha, + &cc_mixed, + &cc_mixed, + &cc_mixed, + &cc_mixed + }; + (*cctype[mode])++; } #endif -} +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h index c2919bbac..91bcc779e 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/fxt1.h @@ -1,38 +1,27 @@ -/* - * FXT1 codec - * Version: 1.1 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * 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 - * DANIEL BORCA 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. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef FXT1_H_included #define FXT1_H_included TAPI int TAPIENTRY -fxt1_encode (int width, int height, int comps, - const void *source, int srcRowStride, - void *dest, int destRowStride); +fxt1_encode(int width, int height, int comps, + const void *source, int srcRowStride, + void *dest, int destRowStride); TAPI void TAPIENTRY -fxt1_decode_1 (const void *texture, int stride /* in pixels */, - int i, int j, byte *rgba); +fxt1_decode_1(const void *texture, int stride /* in pixels */, + int i, int j, byte *rgba); #endif diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h index b1924cbef..820d02cb4 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/internal.h @@ -1,29 +1,20 @@ -/* - * Texture compression - * Version: 1.0 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #ifndef INTERNAL_H_included #define INTERNAL_H_included - /*****************************************************************************\ * Texture compression stuff \*****************************************************************************/ @@ -31,19 +22,12 @@ #define YUV #define ARGB - /*****************************************************************************\ * DLL stuff \*****************************************************************************/ -#ifdef __WIN32__ -#define TAPI __declspec(dllexport) -#define TAPIENTRY /*__stdcall*/ -#else #define TAPI #define TAPIENTRY -#endif - /*****************************************************************************\ * 64bit types on 32bit machine @@ -78,7 +62,6 @@ typedef struct { #endif /* !__GNUC__ */ - /*****************************************************************************\ * Config \*****************************************************************************/ @@ -131,16 +114,15 @@ typedef struct { } \ } while (0) - /*****************************************************************************\ * Utility functions \*****************************************************************************/ void -_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight, - unsigned int outWidth, unsigned int outHeight, - unsigned int comps, - const byte *src, int srcRowStride, - unsigned char *dest); +_mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight, + unsigned int outWidth, unsigned int outHeight, + unsigned int comps, + const byte *src, int srcRowStride, + unsigned char *dest); #endif diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c index 2eb0306fe..511f2225d 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/texstore.c @@ -1,43 +1,28 @@ -/* - * Mesa 3-D graphics library - * Version: 6.3 - * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. - * - * 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 - * BRIAN PAUL 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. - */ - -/* Copyright (C) 2007 Hiroshi Morii - * _mesa_upscale_teximage2d speedup - */ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include "types.h" #include "internal.h" - void -_mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight, - unsigned int outWidth, unsigned int outHeight, - unsigned int comps, - const byte *src, int srcRowStride, - byte *dest) +_mesa_upscale_teximage2d(unsigned int inWidth, unsigned int inHeight, + unsigned int outWidth, unsigned int outHeight, + unsigned int comps, + const byte *src, int srcRowStride, + byte *dest) { unsigned int i, j, k; @@ -45,49 +30,49 @@ _mesa_upscale_teximage2d (unsigned int inWidth, unsigned int inHeight, assert(outHeight >= inHeight); #if 1 /* H.Morii - faster loops */ - for (i = 0; i < inHeight; i++) { - for (j = 0; j < inWidth; j++) { - const int aa = (i * outWidth + j) * comps; - const int bb = i * srcRowStride + j * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } + for (i = 0; i < inHeight; i++) { + for (j = 0; j < inWidth; j++) { + const int aa = (i * outWidth + j) * comps; + const int bb = i * srcRowStride + j * comps; + for (k = 0; k < comps; k++) { + dest[aa + k] = src[bb + k]; + } + } + for (; j < outWidth; j++) { + const int aa = (i * outWidth + j) * comps; + const int bb = i * srcRowStride + (j - inWidth) * comps; + for (k = 0; k < comps; k++) { + dest[aa + k] = src[bb + k]; + } + } } - for (; j < outWidth; j++) { - const int aa = (i * outWidth + j) * comps; - const int bb = i * srcRowStride + (j - inWidth) * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } + for (; i < outHeight; i++) { + for (j = 0; j < inWidth; j++) { + const int aa = (i * outWidth + j) * comps; + const int bb = (i - inHeight) * srcRowStride + j * comps; + for (k = 0; k < comps; k++) { + dest[aa + k] = src[bb + k]; + } + } + for (; j < outWidth; j++) { + const int aa = (i * outWidth + j) * comps; + const int bb = (i - inHeight) * srcRowStride + (j - inWidth) * comps; + for (k = 0; k < comps; k++) { + dest[aa + k] = src[bb + k]; + } + } } - } - for (; i < outHeight; i++) { - for (j = 0; j < inWidth; j++) { - const int aa = (i * outWidth + j) * comps; - const int bb = (i - inHeight) * srcRowStride + j * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } - } - for (; j < outWidth; j++) { - const int aa = (i * outWidth + j) * comps; - const int bb = (i - inHeight) * srcRowStride + (j - inWidth) * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } - } - } #else for (i = 0; i < outHeight; i++) { - const int ii = i % inHeight; - for (j = 0; j < outWidth; j++) { - const int jj = j % inWidth; + const int ii = i % inHeight; + for (j = 0; j < outWidth; j++) { + const int jj = j % inWidth; const int aa = (i * outWidth + j) * comps; const int bb = ii * srcRowStride + jj * comps; - for (k = 0; k < comps; k++) { - dest[aa + k] = src[bb + k]; - } - } + for (k = 0; k < comps; k++) { + dest[aa + k] = src[bb + k]; + } + } } #endif -} +} \ No newline at end of file diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h b/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h index 40e7153ab..7e3d13066 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/types.h @@ -1,3 +1,17 @@ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ + #ifndef TYPES_H_included #define TYPES_H_included diff --git a/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c b/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c index 7bc8d610a..c60ca510d 100644 --- a/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c +++ b/Source/Project64-video/TextureEnhancer/tc-1.1+/wrapper.c @@ -1,24 +1,16 @@ -/* - * Texture compression - * Version: 1.0 - * - * Copyright (C) 2004 Daniel Borca All Rights Reserved. - * - * this 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, or (at your option) - * any later version. - * - * this 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 GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - */ - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2007 Hiroshi Morii * +* Copyright (C) 2004 Daniel Borca * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include @@ -26,85 +18,79 @@ #include "internal.h" #include "dxtn.h" - #define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 #define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 #define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 #define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 - TAPI void TAPIENTRY -fetch_2d_texel_rgb_dxt1 (int texImage_RowStride, - const byte *texImage_Data, - int i, int j, - byte *texel) +fetch_2d_texel_rgb_dxt1(int texImage_RowStride, + const byte *texImage_Data, + int i, int j, + byte *texel) { dxt1_rgb_decode_1(texImage_Data, texImage_RowStride, i, j, texel); } - TAPI void TAPIENTRY -fetch_2d_texel_rgba_dxt1 (int texImage_RowStride, - const byte *texImage_Data, - int i, int j, - byte *texel) +fetch_2d_texel_rgba_dxt1(int texImage_RowStride, + const byte *texImage_Data, + int i, int j, + byte *texel) { dxt1_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); } - TAPI void TAPIENTRY -fetch_2d_texel_rgba_dxt3 (int texImage_RowStride, - const byte *texImage_Data, - int i, int j, - byte *texel) +fetch_2d_texel_rgba_dxt3(int texImage_RowStride, + const byte *texImage_Data, + int i, int j, + byte *texel) { dxt3_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); } - TAPI void TAPIENTRY -fetch_2d_texel_rgba_dxt5 (int texImage_RowStride, - const byte *texImage_Data, - int i, int j, - byte *texel) +fetch_2d_texel_rgba_dxt5(int texImage_RowStride, + const byte *texImage_Data, + int i, int j, + byte *texel) { dxt5_rgba_decode_1(texImage_Data, texImage_RowStride, i, j, texel); } - TAPI void TAPIENTRY -tx_compress_dxtn (int srccomps, int width, int height, - const byte *source, int destformat, byte *dest, - int destRowStride) +tx_compress_dxtn(int srccomps, int width, int height, + const byte *source, int destformat, byte *dest, + int destRowStride) { int srcRowStride = width * srccomps; int rv; switch (destformat) { - case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - rv = dxt1_rgb_encode(width, height, srccomps, - source, srcRowStride, - dest, destRowStride); - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - rv = dxt1_rgba_encode(width, height, srccomps, - source, srcRowStride, - dest, destRowStride); - break; - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - rv = dxt3_rgba_encode(width, height, srccomps, - source, srcRowStride, - dest, destRowStride); - break; - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - rv = dxt5_rgba_encode(width, height, srccomps, - source, srcRowStride, - dest, destRowStride); - break; - default: - assert(0); + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + rv = dxt1_rgb_encode(width, height, srccomps, + source, srcRowStride, + dest, destRowStride); + break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + rv = dxt1_rgba_encode(width, height, srccomps, + source, srcRowStride, + dest, destRowStride); + break; + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + rv = dxt3_rgba_encode(width, height, srccomps, + source, srcRowStride, + dest, destRowStride); + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + rv = dxt5_rgba_encode(width, height, srccomps, + source, srcRowStride, + dest, destRowStride); + break; + default: + assert(0); } /*return rv;*/ -} +} \ No newline at end of file diff --git a/Source/Project64-video/Util.cpp b/Source/Project64-video/Util.cpp index e5ff06318..43c6c37f6 100644 --- a/Source/Project64-video/Util.cpp +++ b/Source/Project64-video/Util.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include diff --git a/Source/Project64-video/Util.h b/Source/Project64-video/Util.h index 4b0dc5b68..27abd49f1 100644 --- a/Source/Project64-video/Util.h +++ b/Source/Project64-video/Util.h @@ -1,44 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -#ifndef Util_H -#define Util_H +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once #define NOT_TMU0 0x00 #define NOT_TMU1 0x01 @@ -55,7 +28,7 @@ void apply_shade_mods(VERTEX *v); void update(); void update_scissor(); -void set_message_combiner(); +void set_message_combiner(void); float ScaleZ(float z); @@ -95,8 +68,8 @@ float ScaleZ(float z); static inline uint32_t bswap32(uint32_t val) { return (((val & 0xff000000) >> 24) | - ((val & 0x00ff0000) >> 8) | - ((val & 0x0000ff00) << 8) | + ((val & 0x00ff0000) >> 8) | + ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24)); } #endif @@ -136,5 +109,3 @@ template static T __ROL__(T value, unsigned int count) value |= high; return value; } - -#endif // ifndef Util_H diff --git a/Source/Project64-video/Version.h b/Source/Project64-video/Version.h index c0def2b0a..11675279e 100644 --- a/Source/Project64-video/Version.h +++ b/Source/Project64-video/Version.h @@ -1,22 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #define STRINGIZE2(s) #s #define STRINGIZE(s) STRINGIZE2(s) @@ -25,19 +19,19 @@ #define VERSION_REVISION 0 #define VERSION_BUILD 9999 -#define VER_FILE_DESCRIPTION_STR "Glide 64 for Project64" +#define VER_FILE_DESCRIPTION_STR "Project64-video" #define VER_FILE_VERSION VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_BUILD #define VER_FILE_VERSION_STR STRINGIZE(VERSION_MAJOR) \ "." STRINGIZE(VERSION_MINOR) \ "." STRINGIZE(VERSION_REVISION) \ "." STRINGIZE(VERSION_BUILD) \ -#define VER_PRODUCTNAME_STR "Glide64" +#define VER_PRODUCTNAME_STR "Project64-video" #define VER_PRODUCT_VERSION VER_FILE_VERSION #define VER_PRODUCT_VERSION_STR VER_FILE_VERSION_STR #define VER_ORIGINAL_FILENAME_STR VER_PRODUCTNAME_STR ".dll" #define VER_INTERNAL_NAME_STR VER_PRODUCTNAME_STR -#define VER_COPYRIGHT_STR "Copyright (C) 2013" +#define VER_COPYRIGHT_STR "Copyright (C) 2017" #ifdef _DEBUG #define VER_VER_DEBUG VS_FF_DEBUG diff --git a/Source/Project64-video/rdp.cpp b/Source/Project64-video/rdp.cpp index d9264cdea..1efcec984 100644 --- a/Source/Project64-video/rdp.cpp +++ b/Source/Project64-video/rdp.cpp @@ -1,42 +1,16 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ #include #include diff --git a/Source/Project64-video/rdp.h b/Source/Project64-video/rdp.h index e7f46f766..58f087337 100644 --- a/Source/Project64-video/rdp.h +++ b/Source/Project64-video/rdp.h @@ -1,44 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -#ifndef RDP_H -#define RDP_H +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once #include @@ -728,4 +701,3 @@ extern int SwapOK; void load_palette(uint32_t addr, uint16_t start, uint16_t count); void setTBufTex(uint16_t t_mem, uint32_t cnt); -#endif // ifndef RDP_H diff --git a/Source/Project64-video/trace.cpp b/Source/Project64-video/trace.cpp index bb4738f68..20c5ef362 100644 --- a/Source/Project64-video/trace.cpp +++ b/Source/Project64-video/trace.cpp @@ -1,3 +1,13 @@ +/**************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ #include "trace.h" #include "Config.h" #include "settings.h" diff --git a/Source/Project64-video/trace.h b/Source/Project64-video/trace.h index a96c7032b..f947b2036 100644 --- a/Source/Project64-video/trace.h +++ b/Source/Project64-video/trace.h @@ -1,3 +1,13 @@ +/**************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* * +****************************************************************************/ #pragma once #include #include diff --git a/Source/Project64-video/turbo3D.h b/Source/Project64-video/turbo3D.h index 5fb7cc053..e3e549201 100644 --- a/Source/Project64-video/turbo3D.h +++ b/Source/Project64-video/turbo3D.h @@ -1,47 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Created by Gonetz, 2008 -// -//**************************************************************** - -/******************Turbo3D microcode*************************/ +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once struct t3dGlobState { uint16_t pad0; diff --git a/Source/Project64-video/ucode.h b/Source/Project64-video/ucode.h index a78057f03..7ffd0b82f 100644 --- a/Source/Project64-video/ucode.h +++ b/Source/Project64-video/ucode.h @@ -1,41 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once typedef void(*rdp_instr)(); diff --git a/Source/Project64-video/ucode00.h b/Source/Project64-video/ucode00.h index 47d3d6e80..d6fe37d5a 100644 --- a/Source/Project64-video/ucode00.h +++ b/Source/Project64-video/ucode00.h @@ -1,42 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void rsp_vertex(int v0, int n) { uint32_t addr = segoffset(rdp.cmd1) & 0x00FFFFFF; diff --git a/Source/Project64-video/ucode01.h b/Source/Project64-video/ucode01.h index 875756431..0aee8873c 100644 --- a/Source/Project64-video/ucode01.h +++ b/Source/Project64-video/ucode01.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -// -// vertex - loads vertices -// +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void uc1_vertex() { diff --git a/Source/Project64-video/ucode02.h b/Source/Project64-video/ucode02.h index 3f4ba0328..e840ef0fd 100644 --- a/Source/Project64-video/ucode02.h +++ b/Source/Project64-video/ucode02.h @@ -1,42 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void calc_point_light(VERTEX *v, float * vpos) { float light_intensity = 0.0f; diff --git a/Source/Project64-video/ucode03.h b/Source/Project64-video/ucode03.h index 995fd2582..1e5698d82 100644 --- a/Source/Project64-video/ucode03.h +++ b/Source/Project64-video/ucode03.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -// -// vertex - loads vertices -// +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void uc3_vertex() { diff --git a/Source/Project64-video/ucode04.h b/Source/Project64-video/ucode04.h index effc05f3d..d23427c51 100644 --- a/Source/Project64-video/ucode04.h +++ b/Source/Project64-video/ucode04.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -//**************************************************************** -// uCode 4 - RSP SW 2.0D EXT -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void uc4_vertex() { diff --git a/Source/Project64-video/ucode05.h b/Source/Project64-video/ucode05.h index f7c6903d2..0413f8f44 100644 --- a/Source/Project64-video/ucode05.h +++ b/Source/Project64-video/ucode05.h @@ -1,41 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once int cur_mtx = 0; int billboarding = 0; diff --git a/Source/Project64-video/ucode06.h b/Source/Project64-video/ucode06.h index a421f9c57..d3eab97d7 100644 --- a/Source/Project64-video/ucode06.h +++ b/Source/Project64-video/ucode06.h @@ -1,43 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** - -// STANDARD DRAWIMAGE - draws a 2d image based on the following structure +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static float set_sprite_combine_mode() { diff --git a/Source/Project64-video/ucode07.h b/Source/Project64-video/ucode07.h index f04c532ac..b9de35b5a 100644 --- a/Source/Project64-video/ucode07.h +++ b/Source/Project64-video/ucode07.h @@ -1,47 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Oct 2002 Created by Gonetz (Gonetz@ngs.ru) -// Info about this ucode is taken from TR64 OGL plugin. Thanks, Icepir8! -// Oct 2003 Modified by Gonetz (Gonetz@ngs.ru) -// Bugs fixed with help from glN64 sources. Thanks, Orkin! -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once uint32_t pd_col_addr = 0; diff --git a/Source/Project64-video/ucode08.h b/Source/Project64-video/ucode08.h index d7c83e081..9b615a167 100644 --- a/Source/Project64-video/ucode08.h +++ b/Source/Project64-video/ucode08.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// January 2004 Created by Gonetz (Gonetz@ngs.ru) -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once uint32_t uc8_normale_addr = 0; float uc8_coord_mod[16]; diff --git a/Source/Project64-video/ucode09.h b/Source/Project64-video/ucode09.h index b0771601e..f5e07a6bc 100644 --- a/Source/Project64-video/ucode09.h +++ b/Source/Project64-video/ucode09.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// December 2008 Created by Gonetz (Gonetz@ngs.ru) -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once void uc9_rpdcmd(); diff --git a/Source/Project64-video/ucode09rdp.h b/Source/Project64-video/ucode09rdp.h index 805593dd5..671ed2b0f 100644 --- a/Source/Project64-video/ucode09rdp.h +++ b/Source/Project64-video/ucode09rdp.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// December 2008 Created by Gonetz (Gonetz@ngs.ru) -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once void uc9_rpdcmd() { diff --git a/Source/Project64-video/ucodeFB.h b/Source/Project64-video/ucodeFB.h index 83c770299..3bf259605 100644 --- a/Source/Project64-video/ucodeFB.h +++ b/Source/Project64-video/ucodeFB.h @@ -1,45 +1,17 @@ -/* -* Glide64 - Glide video plugin for Nintendo 64 emulators. -* Copyright (c) 2002 Dave2001 -* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski -* -* 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 -* 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-1307 USA -*/ - -//**************************************************************** -// -// Glide64 - Glide Plugin for Nintendo 64 emulators -// Project started on December 29th, 2001 -// -// Authors: -// Dave2001, original author, founded the project in 2001, left it in 2002 -// Gugaman, joined the project in 2002, left it in 2002 -// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002 -// Hiroshi 'KoolSmoky' Morii, joined the project in 2007 -// -//**************************************************************** -// -// To modify Glide64: -// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me. -// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all. -// -//**************************************************************** -// -// Creation 13 August 2003 Gonetz -// -//**************************************************************** +/*************************************************************************** +* * +* Project64-video - A Nintendo 64 gfx plugin. * +* http://www.pj64-emu.com/ * +* Copyright (C) 2017 Project64. All rights reserved. * +* Copyright (C) 2003-2009 Sergey 'Gonetz' Lipski * +* Copyright (C) 2002 Dave2001 * +* * +* License: * +* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * +* version 2 of the License, or (at your option) any later version. * +* * +****************************************************************************/ +#pragma once static void fb_uc0_moveword() {