diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-03 11:02:01 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2024-08-12 16:23:54 +0200 |
commit | 685d85a39d1ecc2b9061805a39fff15f0aeef497 (patch) | |
tree | 5ce1236044eff4d02a851823bd2252cdaa0f0612 /common | |
parent | 909e5466e64d438ec6f803c7e284d9a1388ef06c (diff) | |
download | tigervnc-685d85a39d1ecc2b9061805a39fff15f0aeef497.tar.gz tigervnc-685d85a39d1ecc2b9061805a39fff15f0aeef497.zip |
Remove ScaleFilters
This has been unused since 9fe3479.
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/rfb/ScaleFilters.cxx | 129 | ||||
-rw-r--r-- | common/rfb/ScaleFilters.h | 81 |
3 files changed, 0 insertions, 211 deletions
diff --git a/common/rfb/CMakeLists.txt b/common/rfb/CMakeLists.txt index 360434a9..d7fb3f3a 100644 --- a/common/rfb/CMakeLists.txt +++ b/common/rfb/CMakeLists.txt @@ -50,7 +50,6 @@ add_library(rfb STATIC SSecurityStack.cxx SSecurityVncAuth.cxx SSecurityVeNCrypt.cxx - ScaleFilters.cxx Timer.cxx TightDecoder.cxx TightEncoder.cxx diff --git a/common/rfb/ScaleFilters.cxx b/common/rfb/ScaleFilters.cxx deleted file mode 100644 index 823dc740..00000000 --- a/common/rfb/ScaleFilters.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. 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 of the License, or - * (at your option) any later version. - * - * This software 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 software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <assert.h> -#include <math.h> - -#include <rfb/Rect.h> -#include <rfb/ScaleFilters.h> - -using namespace rfb; - -// -// -=- 1-D filters functions -// - -// Nearest neighbor filter function -double nearest_neighbor(double x) { - if (x < -0.5) return 0.0; - if (x < 0.5) return 1.0; - return 0.0; -} - -// Linear filter function -double linear(double x) { - if (x < -1.0) return 0.0; - if (x < 0.0) return 1.0+x; - if (x < 1.0) return 1.0-x; - return 0.0; -} - -// Cubic filter functions -double cubic(double x) { - double t; - if (x < -2.0) return 0.0; - if (x < -1.0) {t = 2.0+x; return t*t*t/6.0;} - if (x < 0.0) return (4.0+x*x*(-6.0+x*-3.0))/6.0; - if (x < 1.0) return (4.0+x*x*(-6.0+x*3.0))/6.0; - if (x < 2.0) {t = 2.0-x; return t*t*t/6.0;} - return 0.0; -} - - -// -// -=- ScaleFilters class -// - -SFilter &ScaleFilters::operator[](unsigned int filter_id) { - assert(filter_id <= scaleFilterMaxNumber); - return filters[filter_id]; -} - -int ScaleFilters::getFilterIdByName(char *filterName) { - for (unsigned int i = 0; i <= scaleFilterMaxNumber; i++) { - if (strcasecmp(filters[i].name, filterName) == 0) return i; - } - return -1; -} - -void ScaleFilters::initFilters() { - filters[scaleFilterNearestNeighbor] = create("Nearest neighbor", 0.5, nearest_neighbor); - filters[scaleFilterBilinear] = create("Bilinear", 1, linear); - filters[scaleFilterBicubic] = create("Bicubic", 2, cubic); -} - -SFilter ScaleFilters::create(const char *name_, double radius_, filter_func func_) { - SFilter filter; - strncpy(filter.name, name_, sizeof(filter.name)-1); - filter.name[sizeof(filter.name)-1] = '\0'; - filter.radius = radius_; - filter.func = func_; - return filter; -} - -void ScaleFilters::makeWeightTabs(int filter_id, int src_x, int dst_x, SFilterWeightTab **pWeightTabs) { - double sxc; - double offset = 0.5; - double ratio = (double)dst_x / src_x; - double sourceScale = __rfbmax(1.0, 1.0/ratio); - double sourceRadius = __rfbmax(0.5, sourceScale * filters[filter_id].radius); - double sum, nc; - int i, ci; - - SFilter sFilter = filters[filter_id]; - - *pWeightTabs = new SFilterWeightTab[dst_x]; - SFilterWeightTab *weightTabs = *pWeightTabs; - - // Make the weight tab for the each dest x position - for (int x = 0; x < dst_x; x++) { - sxc = (double(x)+offset) / ratio; - - // Calculate the scale filter interval, [i0, i1) - int i0 = int(__rfbmax(sxc-sourceRadius+0.5, 0)); - int i1 = int(__rfbmin(sxc+sourceRadius+0.5, src_x)); - - weightTabs[x].i0 = i0; weightTabs[x].i1 = i1; - weightTabs[x].weight = new short[i1-i0]; - - // Calculate coeff to normalize the filter weights - for (sum = 0, i = i0; i < i1; i++) sum += sFilter.func((double(i)-sxc+0.5)/sourceScale); - if (sum == 0.) nc = (double)(WEIGHT_OF_ONE); else nc = (double)(WEIGHT_OF_ONE)/sum; - - - // Calculate the weight coeffs on the scale filter interval - for (ci = 0, i = i0; i < i1; i++) { - weightTabs[x].weight[ci++] = (short)floor((sFilter.func((double(i)-sxc+0.5)/sourceScale) * nc) + 0.5); - } - } -} diff --git a/common/rfb/ScaleFilters.h b/common/rfb/ScaleFilters.h deleted file mode 100644 index 23c87b64..00000000 --- a/common/rfb/ScaleFilters.h +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2006 TightVNC Team. 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 of the License, or - * (at your option) any later version. - * - * This software 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 software; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, - * USA. - */ - -// -=- ScaleFilters.h -// -// Definitions of the 1-D filters and routines using for the image scaling. -// -// - -namespace rfb { - - #define SCALE_ERROR (1e-7) - #define BITS_OF_CHANEL 8 - #define BITS_OF_WEIGHT 14 - #define FINALSHIFT (2 * BITS_OF_WEIGHT - BITS_OF_CHANEL) - #define WEIGHT_OF_ONE (1 << BITS_OF_WEIGHT) - - typedef double (*filter_func)(double x); - - const double pi = 3.14159265358979; - - const unsigned int scaleFilterNearestNeighbor = 0; - const unsigned int scaleFilterBilinear = 1; - const unsigned int scaleFilterBicubic = 2; - - const unsigned int scaleFilterMaxNumber = 2; - const unsigned int defaultScaleFilter = scaleFilterBilinear; - - // - // -=- Scale filters structures and routines - // - - // Scale filter stuct - typedef struct { - char name[30]; // Filter name - double radius; // Radius where filter function is nonzero - filter_func func; // Pointer to filter function - } SFilter; - - // Scale filter weight table - typedef struct { - short i0, i1; // Filter function interval, [i0..i1) - short *weight; // Weight coefficients on the filter function interval - } SFilterWeightTab; - - - // ScaleFilters class helps us using a set of 1-d scale filters. - class ScaleFilters { - public: - ScaleFilters() { initFilters(); }; - - SFilter &operator[](unsigned int filter_id); - - int getFilterIdByName(char *filterName); - - void makeWeightTabs(int filter, int src_x, int dst_x, SFilterWeightTab **weightTabs); - - protected: - void initFilters(); - - SFilter create(const char *name_, double radius_, filter_func func_); - - SFilter filters[scaleFilterMaxNumber+1]; - }; - -}; |